In 1969, the town of Junction Flats became famous after Sheriff Morrison Pyne captured Hognose Hughes and locked him up. Unfortunately, Hognose escaped his cell, ties up Pyne, killed thirteen people, and rode out of town.
Now, Bret Maverick rides into the town of Broken Wheel, a few miles from Junction Flats. He runs into Dandy Jim Buckley at the local saloon and Buckley asks him for money. When Bret refuses, Buckley insists that he's gone legitimate but needs $2,000 to buy up the local horses and sell them to a group of buyers. He offers Bret a $4,000 return on the loan after he makes the sale. Bret reluctantly agrees, curious to find out exactly what Buckley is up to.
Buckley buys up every horse in the territory as Bret watches him. Everything goes according to plan until Bret looks out one morning and discovers that everyone has left town. A saloon keeper is preparing to ride out and tells Bret that a prospector reported gold at nearby Cobbs Creek. Everyone has left town to place their claim, and the saloon keeper rides off to place his own. Bret realizes what is happening and goes to find Buckley. Buckley is stealing Bret's horse and preparing to ride out of town with the $10,000 that he collected. He offers to split the money with Bret, who figures that the townspeople will soon be coming back for their money once they realized that Buckley paid off the prospector to report a fake gold strike.
The two men ride out and the townspeople are soon on their trail. Bret and Buckley stop to split up the money, and Buckley can't believe that Bret plans to give his money back to avoid jail time. The next morning, Bret wakes up and discovers that Buckley has tied him up and taken his share of the $10,000. Bret follows Buckley's trail to Junction Flats and talks to a helpful bartender. The mas Bret not to bring up to the topic of Hognose Hughes since Pyne is still sheriff and doesn't like to be reminded of his famous failure. The bartender explains that Buckley showed up with $75 and started playing poker, and ended up shooting and wounding a cheater, Lee Roy. Lee Roy is the sheriff's nephew and Pyne threw Buckley in jail for the shooting. The nephew is popular with the townspeople and the bartender figures that the people will soon lynch Buckley.
Bret goes to the jail but discovers that Pyne has had a new one built. He enters the jail office and represents himself as a lawyer offering to defend Buckley. Pyne agrees to let him see Buckley, removes the cell door keys from a safe, and has his deputy, George, make sure that Bret is unarmed. The sheriff then leads Bret through three separate cell doors to meet with his client. Buckley plays along and Pyne refuses to leave until Bret threatens to publicize the case, and Pyne's potential mistreatment of the prisoner, to everyone in the territory.
Once they're alone, Bret asks where the $10,000 is and Buckley refuses to tell him unless Bret gets him out of jail. Bret agrees but renegotiates a 60/40 split since he's doing the extra work. Once he's outside, Bret checks the jail and realizes that the only way in is through the floor. He goes to a next-door dress top and asks the owner, Madame Higgins, for a dress for his mother. Once she leaves the main room, Bret finds the cellar door. When Higgins returns, he asks her for a different dress. Bret then goes to his horse, gets some digging equipment, and hides in the basement. Higgins comes back and has no idea where he is, and assumes that he left, unaware that Bret is digging through to the jail.
The next morning, Buckley hears Bret digging and realizes what is going on. Higgins hears Bret digging and calls in a man to help. They find Bret in the cellar and the man attacks him. Bret manages to keep crates from falling over and Higgins from getting help, all while knocking out the man. He then ties up Madame Higgins and starts digging again.
As Bret gets close to the cell's floor, Buckley starts playing a harmonica and stomping on the floor to make sure that Deputy George doesn't hear the noise. The deputy starts singing along in the next room. However, when Buckley grows quiet, Deputy George finally investigates and discovers that Buckley has escaped.
The two men leave town and Bret has Buckley split up the money. He then ties the con man up and explains that he's going back to Junction Flats to clear both of their names. Buckley is less than thrilled and Bret assures him that he'll thank Bret. Some day.
Bret returns to the jail and offers to bring Buckley back in return for Pyne's promise to keep Buckley safe from the lynch mob. The sheriff informs Bret that Lee Roy woke up and confessed that he drew first at the poker game. Relieved, Bret starts to go but Pyne stops him and explains that while a little mischievous shooting is okay, a jail break is a threat to his authority and a deliberate crime. He's spotted the dirt underneath Bret's fingernails and arrests him for engineering the jailbreak.
That night, Pyne goes home for the evening and Buckley knocks at the door. He reminds Deputy George that he's a fugitive from justice and allows himself to be arrested. Deputy George worries that they don't have enough cells to hold two prisoners, and Buckley easily disarms him. After locking the deputy up, Buckley cheerfully assures Bret that he's a master safecracker and goes to work on the safe containing the cell keys.
At home, Pyne worries that something might be going wrong. He starts to leave for the jail but Mrs. Pyne tells him to stop worrying for once and go to bed.
Buckley continues to work on the safe and regales Bret with a story about Robert the Bruce and persistence. He forgets the ending of the story and goes back to work, while Deputy George tells them that the sheriff will soon be back.
The next morning, Pyne comes to work and discovers Deputy George handcuffed to the cell door. Buckley is waiting for him and captures him at gunpoint. He and Bret head for the door and Pyne begs them to shoot him so he doesn't have to endure the humiliation of another jailbreak on his watch. Buckley points out that murder is against the law and leaves.
Outside town, Bret and Buckley split up the money one last time. Bret insists on keeping his gun. As Buckley mounts up, he asked whatever happened to the infamous Hognose Hughes, and Bret explains that he died eating bad chili. They ride off in opposite directions, but Buckley doubles back and rides off after Bret. Bret, anticipating a double-cross, has hidden and rides off in Buckley's first direction. However, Buckley figures what Bret is up to, doubles back again, and catches Bret at supper unawares. After tying up Bret, Buckley cheerfully rides off with the entire $10,000.