Up to 1869, the town of Junction Flats became famous when Sheriff Morrison Pyne captured Hognose Hughes. Hognose escaped after tying up Pyne, killing thirteen people in the process.
Eight years later, Bret passes through Broken Wheel near Junction Flats. He runs into Dandy Jim Buckley, who promptly asks him for money. He claims that he’s turned honest but still needs $2,000 for a loan to buy horses to sell at top price. In return, Dandy Jim offers a $4,000 return once he makes the sale. Bret can’t resist if for no other reason than to find out what Dandy Jim is up to. He gives Dandy Jim the $2,000 and watches over the next few days as Dandy Jim buys every horse in town.
Early one morning in the middle of the week, Bret has discovered that everyone has left. He talks to a saloon owner who explains that a prospector found gold at Cobb’s Creek and everyone has run off to start mining. The saloon owner pays off Dandy Jim for the info and tries to ride off with Bret’s horse, but Bret catches up to him. Dandy Jim offers to split the $10,000 he’s collected with Bret, but Bret figures that the town’s population will soon be coming back for a refund. Dandy Jim and Bret quickly ride out of Broken Wheel and the townspeople pursue them. The two men stop long enough to split the money and Bret says that he’s going to give his back.
When Bret wakes up the next morning, he discovers that Dandy Jim has tied him up and taken the money. Bret follows him to Junction Flats and talks to the saloon’s bartender. The gambler soon remembers the story of Hognose Hughes and his jail break, but the bartender tells him that Sheriff Pyne isn’t interested in hearing about his failure. Bret asks after Dandy Jim and learns that he entered the saloon, accused another player of cheating at poker, and ended up shooting the cheater, Lee Roy. The sheriff is Lee Roy’s uncle and has thrown Dandy Jim in jail. Bret takes an interest when he learns that Dandy Jim only lost $75, while the bartender hints that a lynch mob is gathering.
Bret goes to the new jail and discovers that it’s an impregnable brick fortress. He approaches the sheriff and claims to be a lawyer offering to defend Dandy Jim. Sheriff Pyne reluctantly agrees and takes the keys out of a safe while his deputy, George, searches Bret for any weapons. The lawman takes Bret through several locked doors and introduces him to Dandy Jim, who feigns ignorance and plays along. Pyne refuses to leave them alone until Bret hints that the whole country will know if anything illegal happens to Dandy Jim.
Once the two men are alone, Bret demands to know where the money is. Dandy Jim refuses unless Bret breaks him out of jail. Bret reluctantly agrees but insists on a 60/40 split for his “legal fees.” When Pyne returns, Dandy Jim realizes that he has no choice but to agree. Outside, Bret examines the jail and tries to figure a way to break Dandy Jim out. He finally goes to the dress store next door and asks the owner, Madame Huggins, for a tied-back dress. When she goes to get it, Bret locates the cellar door. Once Madame Huggins comes back, he asks for a different dress. When she goes back, Bret goes to his horse and gets a bundle, and then takes it down to the basement. When Madame Huggins returns, she’s surprised to see that he’s gone. Meanwhile, Bret takes out a lamp and some digging tools from the bundle and starts digging through the wall toward the jail.
The next morning, Dandy Jim hears Bret digging beneath the floor. Madame Higgins arrives for the morning and hears Bret breaking through the floor of the jail. She runs out to get a man to deal with the person responsible. They go downstairs and Bret tries to knock the man out while keeping as quiet as possible. Once he succeeds, he ties Madame Higgins up and starts digging again. When Pyne comes in with breakfast, Dandy Jim plays a harmonica to cover the digging noises and stomps on the floor until Bret gets the idea.
Once Pyne leaves, Dandy Jim continues to play and sing so Deputy George doesn’t hear Bret break through the floorboards. When things go quiet, Deputy George finally investigates and discovers that Dandy Jim has escaped.
Out in the woods, Bret has Dandy Jim count out the money and then ties him up. He explains that he has to go back to Junction Flats to clear Dandy Jim’s name and his own at the same time. Bret assures Dandy Jim that he’ll thank him... some day.
Back at the jail, Bret negotiates with Pyne and asks for the sheriff’s personal guarantee that Dandy Jim will be kept alive until the circuit judge arrives. Pyne admits that his nephew woke up and admitted that he drew first. However, the sheriff stops Bret and tells him that shooting people is one thing, but deliberately breaking someone out of jail is a crime. Pyne spots the dirt under Bret’s fingernails and tells him that he’ll be staying in jail until he’s sentenced for thirty years.
Once Pyne leaves for the night, Bret waits for Dandy Jim to free himself and ride into town to rescue him. As Deputy George stands guard, there’s a knock at the jail door. It’s Dandy Jim, who introduces himself as a fugitive from justice and Deputy George arrests him. However, he’s disappointed that they don’t have a cell and that Pyne won’t be back until morning to deal with two prisoners. Dandy Jim easily disarms him but Bret points out that they don’t have the cell keys. In response, Dandy Jim goes to work on the safe and warns that it will take some time.
Sheriff Pyne is at home with Mrs. Pyne and tells her that something is worrying him. He decides to go to the jail, but she tells him to take some time off for once and go to bed.
When he can’t get the safe open, Dandy Jim talks about Robert the Bruce but can’t remember how the story turned out. He continues working and figures that Deputy George is waiting for Pyne to return.
The next morning, Pyne arrives at the jail and gets no response to his knock. He finds the door open and Deputy George handcuffed to a cell door. Dandy Jim captures Pyne at gunpoint and gives his gun to Bret, and then locks Pyne up in his own jail. As Bret and Dandy Jim leave, Pyne begs them to shoot him rather than bear the humiliation again, but Dandy Jim points out that murder is against the law.
Dandy Jim and Bret divide up their money one more time and Dandy Jim prepares to ride off. Bret insists on keeping his gun. As Dandy Jim leaves, he asks what happened to Hognose Hughes, and Bret explains that the killer died of bad chili. The two men ride away in opposite directions… but Dandy Jim rides off after Bret. He’s unaware that Bret has hid and then rides back the way Dandy Jim came from.
Later, Bret is making supper when Dandy Jim catches up to him and captures him with a stolen buffalo rifle. He ties up Bret and rides away with the entire $10,000.