In 1881, Chon Wang (Jackie Chan) – a homophone for John Wayne – is a Chinese Imperial Guard in the Forbidden City. After Princess Pei-Pei (Lucy Liu) is abducted to the United States, the Emperor of China sends three of his guards and the Royal Interpreter (Henry O) to retrieve her. Having failed to foil the kidnapping, Wang insists on joining the mission. The Royal Interpreter, Wang’s uncle, allows him to accompany the party, and the Captain of the Imperial Guards hopes the “foreign devils” will get rid of Wang. The party arrives in Nevada, where outlaw Roy O’Bannon (Owen Wilson) and his gang hijack their train. Wallace (Walton Goggins), a new member of Roy’s gang, kills Wang’s uncle, and Wang, a skilled martial artist, fights off the gang before uncoupling the train cars and escaping on the engine. Wallace takes over the gang, leaving Roy buried up to his chin in the desert. Meanwhile, Pei-Pei, tricked into believing she was freely escaping her arranged marriage in China, learns she has been kidnapped by an agent of Lo Fong (Roger Yuan), a traitor who fled the Forbidden City.
Wang finds Roy and demands to know the direction to Carson City. Roy tells him the city is on the other side of a mountain, and Wang leaves two chopsticks in Roy’s mouth to dig himself out. Reaching the other side of the mountain, Wang saves a Sioux boy from the Crow tribe and reluctantly marries the Sioux chief’s daughter, Falling Leaves (Brandon Merrill). Wang finds a small town and encounters Roy in a tavern, inciting a barroom brawl. The two are sent to jail, and after Falling Leaves helps them escape, become friends. Roy trains Wang in the ways of the cowboy, assisted by Falling Leaves.
In Carson City, Roy discovers that both he and Wang, now known as the “Shanghai Kid,” are wanted by Lo Fong’s ally Marshal Nathan Van Cleef (Xander Berkeley), narrowly escaping capture. They reach Roy’s “hideout” (a bordello), but are arrested by Van Cleef after a drunken encounter with Wang, and discover that Lo Fong is behind the princess’ abduction. As they are about to be hanged, Wang frees himself and Falling Leaves shoots Roy loose, and they escape. Wang, upset at overhearing Roy tell a prostitute he is not Wang’s friend, rides off alone. He finds Pei-Pei in Lo Fong’s labor camp, but she wishes to stay and help the enslaved Chinese laborers. Lo Fong discovers Wang and attacks him, but Roy appears, saving Wang.
The next day, the Imperial Guards bring gold to the Carson City Mission church to ransom Pei-Pei from Lo Fong, but the exchange is complicated by the appearance of Wang and Roy. Wang tells his fellow guards he will not allow them to take the princess against her wishes. As the Guards and Lo Fong fight, Van Cleef arrives and engages Roy in a gunfight. Roy survives unscathed, and shoots Van Cleef through his sheriff’s star. Wang fights the Imperial Guards as Lo Fong chases Pei-Pei through the rafters of the church, but Wang convinces his Guards to let him go to Pei-Pei’s aid instead. Wang and Lo Fong reach the bell tower, and Pei-Pei is wounded. Wang dismantles the bell, causing the ropes to strangle Lo Fong. The Imperial Guards agree to let Pei-Pei remain in Nevada, and reward Wang and Roy with the ransom gold.
Wallace and his gang arrive at the church, and demand that Roy and Wang come out and fight, but find themselves surrounded by the Sioux. At a Chinese cultural celebration, Roy shares a passionate kiss with Falling Leaves while Pei-Pei embraces Wang. Roy, who reveals his real name to be Wyatt Earp, and Wang become sheriffs and ride off after a new band of train robbers.