A pair of Indian medicine men discover a wounded bandit clawing his way out of a mass grave, and they take him in to nurse him back to health. As he regains strength, the man recalls a brutal past: a Wells Fargo wagon guarded by U.S. Army troops that was raided by his gang, a raid in which they killed the troops, swam away with a heavy strongbox of powdered gold, and escaped. Yet betrayal shattered the crew—Oaks and some white members turned on the Stranger and the Mexican bandits, forcing them to dig their own graves before gunfire ended their lives. In the present, the medicine men tell the Stranger that they have melted his share of the gold into bullets and that they wish to join him, hoping to hear about the fabled happy hunting ground.
In the nearby town they approach, a place the locals call The Unhappy Place, to trade their gold for horses and supplies. Bill Templer, who runs the saloon, recognizes Oaks from a Wanted poster, and with Elizabeth Hagerman as his wife, he helps lead an armed mob against the bandits. The town’s pastor, Alderman, joins the mob, and the attackers succeed in lynching many of the bandits, leaving Oaks to barricade himself inside a store. The Stranger arrives, and in a tense confrontation shoots down Oaks; the wounded leader is treated in the saloon, but the crowd later rips the gold bullets from his body and he dies. The Stranger spends the night inside the same saloon, haunted by the violence and the pall of greed that surrounds it.
Meanwhile, the quarrel over the bandits’ gold intensifies. Templer and Alderman argue over their supposed shares, while Flory, Templer’s mistress, watches with growing arousal as the tension mounts. Evan, Templer’s unstable son, destroys some of Flory’s clothing in a fit of jealousy and rage. The eccentric rancher Sorrow, together with his faction, demands that the Stranger surrender the treasure, keeping his own power in the town by force.
When the Stranger and the Indians cut down the hanging bodies of the bandits to bury them, they’re ordered to leave. While they’re out riding, the Stranger witnesses Evan being grabbed by Sorrow’s gang and taken to his ranch. Sorrow offers work and throws a party, then sends a messenger to inform Templer of the kidnapping. Templer lies, saying Alderman holds the gold; Sorrow responds with a brutal order to kill Evan. The Stranger intervenes during a drunken shooting game and saves Evan, but Sorrow allows him to live. The next morning, driven by despair, Evan takes his own life.
The Stranger returns to town with Evan’s corpse. Enraged, he storms into a brutal brawl with Templer and several locals. Knowing Sorrow will search the saloon, Flory and Templer hide the gold inside Evan’s coffin. Alderman invites the Stranger to live with him and tries to set up a relationship with Elizabeth, who is kept locked away and who becomes drawn to the Stranger. The bond between them grows, but Alderman shoots Templer with the Stranger’s pistol and tries to pin the murder on him. Flory witnesses the deed and flees, later revealing that the gold now rests in the cemetery. Alderman rallies the townspeople for a graveyard search; during the raid, an Indian is scalped and Flory is fatally shot by Alderman.
Sorrow’s muchachos capture the Stranger, crucify him, and torture him with vampire bats, forcing a confession that the treasure lies in the cemetery. Sorrow’s gang digs up the graves, only to find that Alderman has already hauled away the gold. A surviving Indian frees the Stranger, who then dispatches Sorrow’s men using a horse laden with dynamite and shoots Sorrow in his boudoir.
The Stranger returns to town to find Elizabeth’s fury and Alderman’s house set aflame. Alderman opens a cabinet hoping to reclaim the gold, but the metal has turned molten and smothers his hands and face. As the town watches in dark awe, Elizabeth and Alderman, both coated in molten gold, perish in the flames. In the end, the Stranger rides away from the burning town, passing two children who distort their faces with strings, a final haunting image of a world scarred by greed and vengeance.