A frontier town in the Old West springs up almost literally overnight when the rather klutzy and hotheaded Prudy Perkins discovers gold in a grave during a funeral. Her father Olly becomes mayor of the new settlement. He and the other members of the town council bemoan the twin facts that the place has become a drunken round-the-clock free-for-all, and that in order to ship out all the gold they are mining, they must pay a hefty fee to the Danbys, a family of ranchers/bandits who control the only route out of town. Most people are too busy digging to take time out to be sheriff, and those who are willing to put down their shovel quickly die.
This all changes with the arrival in town of Jason McCullough, a calm and hyper-competent man from "back East" who is passing through town "on his way to Australia." While in the town saloon, he sees young Joe Danby gun a man down, essentially for fun. Needing money after discovering the town's ruinious rate of inflation, McCullough demonstrates his uncanny firearms ability to the mayor and town council, and becomes the new sheriff. He breaks up a street brawl and while at the Perkins house meets Prudy under (for her) mortifyingly embarrassing circumstances. McCullough then arrests Joe and tosses him in the town jail, which has everything a sheriff needs - except iron bars for the cell doors and windows. McCullough keeps the none-too-bright Joe "imprisoned" through the use of a chalk line, some dribbles of red paint, and applied psychology.
In the process of all this, McCullough acquires a semi-willing deputy in the form of the extremely scruffy Jake, who was previously nothing more than the "town character." The arrest ignites the wrath of the patriarch of the Danby family; while the rest of the town immediately quiets down under McCullough's reign, "Pa" mounts various efforts to get Joe out of jail. None of them work and he then brings in a string of hired guns, who are equally unsuccessful. Meanwhile, Prudy spars romantically with McCullough, McCullough and Jake go on an unsuccessful search for gold, and, much to Joe's relief, bars are finally installed in the jail.
The climax of the film sees Pa Danby summoning scores of his relatives to launch an all-out assault. The sheriff's first impulse is to just leave town and resume his trip to Australia, but when Prudy expresses her sincere approval of this sensible idea, he announces that it sounds cowardly and decides to stay. The rest of the townfolk announce their disapproval of his new plan, and officially vote to not help in any way. Thus the Danby mob rides in faced only by McCullough, Jake and Prudy. After a lengthy gunfight, McCullough bluffs his way to victory using hostage Joe and the cannon mounted in the center of town. As the Danbys are all marched off to jail, the cannon fires, smashing the town brothel and scattering the resident prostitutes and visting civic leaders. McCullough makes his peace with the townfolk, he and Prudy get engaged, and he carries her home. In a closing monologue, Jake directly informs the audience that they get married and McCullough goes on to become governor of the state, while he, Jake, becomes sheriff and then "one of the most beloved characters in western folklore."