For troubled hero Jake Holman (Steve "Lightning" McQueen), no good deed goes unpunished.
Transferred in 1926 to the U.S.S. San Pablo (whose crew is nicknamed the "Sand Pebbles"), a gunboat serving on the Yangtze River Patrol in China, engineer Holman finds that Chinese coolies are actually doing most of the work on the ship. When he insists on working on the ship's engines himself, he earns the enmity of the Chinese "boss" of the engine room. Captain Collins (Richard Crenna) dismisses Holman's warnings that the machinery needs significant maintenance, and when the ship experiences inevitable engine troubles, the engine room boss is crushed to death by a giant piston when Holman lets him attempt the repair. The head coolie boss bitterly blames Holman for the accident.
Told to train a replacement for the dead man, Holman chooses Po-Han (Mako), whom he also befriends, overcoming his bigoted assumptions about the intellectual abilities of the Chinese. Holman sticks up for Po-Han against a bully, and sets him up to win in a prize fight against his tormentor, crewman Stawski (Simon Oakland). Shipmate Frenchy (Richard Attenborough) uses the money to pay for the freedom of a young Chinese woman, Maily (Emmanuelle Arsan), saving her from a life of prostitution. Po-Han is later captured and tortured by a Communist mob because he works for the Americans. The captain attempts to pay ransom money to trade for Po-Han, but is ignored by the mob. Unable to save his friend, Holman shoots Po-Han to end his suffering. This further enrages the Communists, and the captain rebukes Holman for disobeying orders. The Captain informs Holman that because of his meddling, two crew workers have died and he intends on having him transferred out of the San Pablo.
Frenchy eventually marries Maily in a makeshift ceremony witnessed by Holman and his love interest, Shirley Eckert (Candice Bergen), an American teacher at the China Light Mission. The Chinese form a naval blockade around the San Pablo, but Shirley is able to return to the mission accompanied on a boat with a student leader. When increasing tensions with the Chinese force the Americans to spend all winter on board under siege, Frenchy slips overboard and swims to shore to visit Maily. Made desperately ill by exposure to the cold water, Frenchy ignores Maily's pleas to return for medical care. Holman, permitted to go ashore to deliver the ship's mail to the US Consulate, visits them, but finds that Frenchy has died the night before. Holman pleads with Maily to leave with him to the China Light Mission for protection, but is interrupted by Chinese thugs. Anti-American nationalists kill Maily and her unborn child, and frame Holman for the murder. He makes it back to the ship where his fellow sailors come close to mutiny when the Captain refuses to hand over Holman to the Chinese for prosecution. Feeling that he has lost command of his ship, the captain contemplates suicide.
Just as spring arrives, bringing a rise in the river water levels and the opportunity to escape the siege, news reaches the San Pablo that revolutionaries have begun open violence against Americans in Nanking. The captain ignores orders to return to the coast and goes to attempt to rescue the Americans at China Light Mission. -- Shirley Eckert and the idealistic missionary Jameson (Larry Gates). To reach the mission, the gunboat must break through a blockade of junks manned by the very same boys educated at the missionary school, including the student leader who had been protecting Jameson. Holman has to cut through a thick boom rope with an axe in order to break through the blockade. Holman kills a student leader with the axe near the end of the fighting between the sailors and junk blockaders. The captain decides to take a small group to rescue the missionaries and informs the Ensign to sail back to the coast if the rescue party cannot return in time. The captain and a few men, including Holman, reach the nearly abandoned mission compound to find Jameson and Shirley reluctant to leave. Jameson says that he is a "stateless person" and has renounced his citizenship with his submission of a document to Geneva, so the rescue attempt is not justified since he no longer considers the US to be his protector. He says that the students will protect him and Shirley. Jameson insists that the missionaries are in danger only because of the actions of the American gunboat personnel who back the warlords. The captain refuses to listen to Jameson and insists on escorting them out of the mission because of the imminent danger. Collins tries to have Jameson and Shirley forcibly removed from the mission, but Holman refuses the order to do that and informs the Captain of his desire to remain with them. As Collins and Holman are arguing, one of the student leaders arrives wounded at the mission after having been shot by troops, but after talking to Jameson, he is then subsequently shot dead by Chinese soldiers. Jameson attempts to communicate with the soldiers saying that he is not tied to the American foreigners anymore, but is also shot. When the captain is killed attempting to provide cover for the others to escape, Holman takes his place, remaining behind while the other sailors slip away with Shirley to freedom. Holman shouts out loud commands in an attempt to keep the focus of attention of the soldiers on him only. He kills several snipers from the rooftops. Holman tries to escape too, before he is shot. His dying words are, "I was home. What happened? What the hell happened?"