Wild Wild West

In 1869 U.S. Army Captain James West and U.S. Marshal Artemus Gordon hunt for Confederate General "Bloodbath" McGrath, who is wanted for mass murder, throughout the Southern United States. This is due to McGrath ordering a massacre in a settlement called New Liberty, where many of the freed slaves were murdered, including West's biological parents. The search leads to a brothel where the two try (unsuccessfully) to arrest him. It leads to a huge brawl and a cart of nitroglycerin crashing into the building, starting a fire. Both West and Gordon - the latter dressed as a woman - escape. Later, in Washington, D.C., West and Gordon meet at the White House with President Ulysses S. Grant, who tells them about the disappearance of America's key scientists and a treasonous plot by General "Bloodbath" McGrath. Grant charges the two with finding the scientists before he inaugurates the first transcontinental railroad at Promontory, Utah.
On board their train, Gordon examines the head of a murdered scientist, using a projection device to reveal the last thing the scientist saw. Finding McGrath and a clue in the image, they head to New Orleans, pursuing a lead about Dr. Arliss Loveless, an ex-Confederate scientist in a steam-powered wheelchair, who is hosting a party for the elite of Southern society. West mistakes a female guest for a disguised Gordon and makes an error that results in the guests wanting to lynch West. Meanwhile, Gordon roams the mansion and comes across a caged Rita Escobar, rescuing her. Gordon frees West from the lynching with an elastic rope, and the three escape to their train The Wanderer. On board, Rita asks for their help in rescuing her father, one of the kidnapped scientists, Professor Escobar.
Later, Loveless hosts a reception to demonstrate his newest weapon: a steam-powered tank. The tank uses General McGrath's soldiers as target practice, which angers McGrath. When McGrath demands an explanation, Loveless accuses him of "betrayal" for surrendering at Appomattox, then shoots McGrath and leaves him for dead. As Loveless and his troops head over to Utah, Gordon, West and Rita find the dying McGrath, who reveals that he was framed by Loveless for the massacre of New Liberty, explaining that Loveless used the tank to kill the people there. The three then pursue Loveless on The Wanderer, but having expected their arrival and using steam-powered hydraulics, Loveless maneuvers his train behind The Wanderer. West manages to disable Loveless' train, but not before Loveless uses a cannon-launched grappling hook to stop The Wanderer. Rita, afraid of being recaptured by Loveless, grabs one of Gordon's explosive rigged pool balls and accidentally releases sleeping gas that knocks out West, Gordon, and herself.
West and Gordon wake up as Loveless and his posse pull away in The Wanderer taking Rita hostage, announcing that he intends to capture President Grant at the "golden spike" ceremony and also that West and Gordon will be killed should they step outside of the trap they are in. Escaping the trap, the two stumble across Loveless' private rail line, which leads them to his industrial complex, hidden in Spider Canyon. Here, they witness Loveless' ultimate weapon: a gigantic mechanical spider armed with two nitroglycerin cannons. Loveless uses the spider to capture President Grant and Gordon at the ceremony at Promontory Point, while West is seemingly shot by one of Loveless' bodyguards.
At his industrial complex, Loveless reveals his plan: to destroy the United States with his mechanized forces unless President Grant agrees to divide the states among Great Britain, France, Spain, Mexico, the Native American people, and himself. When Grant refuses to surrender, Loveless tries to have Gordon shot in the head. However, West, who had survived thanks to a chain mail vest Gordon gave him, disguises himself and manages to distract Loveless, allowing Gordon to free the captives. Unfortunately, Loveless escapes on his spider in the ensuing battle, taking the President with him.
To save the President, Gordon and West build a flying machine to overtake the spider as Loveless attacks a small town in an attempt to force Grant to sign the surrender. Gordon and West crash onto the spider, but manage to grab on the beam before they can fall and Munitia, one of Loveless's henchwomen, falls to her death after the collision. After West defeats the henchman below, a fight ensues between him and Loveless, now on mechanical legs. Gordon shoots a hole in Loveless's hydraulic line, allowing West to gain the upper hand. This allows Gordon and Grant to defeat Loveless' guards, and pleading for his life, Loveless drags himself back to his wheelchair as the spider approaches a cliff. Loveless attempts to shoot West with a concealed gun, but hits the spider's steam pipes, stopping it just before it plunges into the canyon. The abrupt stop leaves West and Loveless hanging precariously from the spider. Loveless tries to decide whether he should pull the chair's lever that will release them or not, knowing it will send both him and West to their deaths if he does so. Loveless taunts West so much that West pulls the lever himself and survives by grabbing the ankles of a man hanging from a chain (West had thrown him out earlier), while Loveless falls to his death.
Grant promotes Gordon and West as Agent #1 and Agent #2 of his new U.S. Secret Service. Gordon asks which of them is 1 and 2, but the President brushes off the question as unimportant and tells them they will have plenty of time to talk about on the way back. (Since the President lost his train, he takes "The Wanderer" for the ride back) Gordon and West meet Rita again, both planning to court her, but she crushes their hopes, announcing that Professor Escobar is actually her husband.
The last scene of the film shows Gordon and West riding through the desert. Gordon asks West "Mind if I ask you a question?" West replies "Actually, I do, Artie." The camera pans out to show they are actually riding the mechanical spider.

Question: Who released sleeping gas?
Answer: Rita