Sheriff John T. Chance (John Wayne), along with his deputy Dude (Dean Martin), arrest Joe Burdette (Claude Akins) for murder. Joe's brother Nathan Burdette (John Russell) is a wealthy land owner with several hired guns. He vows to get his brother out of jail before the U.S. Marshal comes to town in six days. That same day, a wagon train enters the town that includes a woman named Feathers (Angie Dickinson) and a young man named Colorado (Ricky Nelson).
Burdette and his men attempt to kill Chance and Dude several times, but without success. During one attempt, the wagon master is killed. Chance orders the wagon train to stay in town until the marshal arrives. With the wagon train now stuck in town, Feathers takes a job at the local hotel/saloon. Chance and her later start a relationship. Dude, who is a recovering alcoholic, tries to remain sober while fighting Burdettes' men with limited success. Another deputy named Stumpy (Walter Brennan), who has a pronounced limp, is always guarding the prisoners and never leaves the jailhouse.
Colorado saves Chance's life during another attempt, and agrees to become a deputy. In a later attempt, Burdette kidnaps Dude and proposes a swap of Dude for Joe to Chance. He agrees, and sets it up near the parked wagon train. During the swap, a gunfight begins. Chance and all of the deputies kill several of Burdette's men, but he and the rest are holed up in a house. Chance uses dynamite from the wagon train to get the men out. With the house nearly destroyed by the dynamite, Burdette surrenders. Now both Joe and Nathan are in jail, along with the surviving hired guns.
At the end, Chance and Feathers continue their relationship, Dude vows to never drink again, Colorado agrees to take over jailhouse guard duty, and Stumpy is finally allowed to patrol the streets.