One day, The Stranger, a black-clad cowboy wearing a flat-crowned black hat and grizzled beard rides from out of the wasteland and into the town of Lago, passing an unmarked grave on his way. As he strides into the saloon, the ringing of his spurs pierces the silence that has descended upon the town with his arrival. Once inside, the stranger is challenged by gunslingers Bill Borders, Tommy Morris and Fred Short. After staring them down with a steely glare, the stranger grabs a bottle of liquor and proceeds to the barber shop for a bath and a shave. The gunslingers follow him there, and when they begin to insult him, the stranger shoots and kills them. Impressed by the stranger’s audacity, Mordecai, a dwarf who is ridiculed by the townsfolk, runs into the barber shop, lights the stranger’s cigar and asks his name. Not bothering to answer him, the stranger walks out into the street, where he collides with Callie Travers, who has had serial affairs with several men in the town. When she upbraids him for walking into her, he pulls her into the barn and rapes her. Proceeding to the hotel owned by Lewis Belding, the stranger refuses to register, then goes upstairs to his room. Upon falling asleep, the stranger dreams of being lashed to death with a bullwhip as the people of Lago watch. The following morning, at the Lago Mining Office, Dave Drake and Morgan Allen, the owners of the mining company, convene a meeting with Mayor Jason Hobart, Sheriff Sam Shaw and other prominent members of the community to discuss the impending release from prison of Stacey Bridges, and brothers Dan and Cole Carlin, who had sworn to return to town and burn it to the ground. Borders, Morris and Short had been hired by the Lago Company to protect the town from Bridges and the Carlin brothers, but Dave and Morgan now propose hiring the stranger to protect them. Just then, Callie runs in screaming, demanding that Morgan, her lover, charge the stranger with rape. When Morgan refuses, Callie spits in his face, and later, Shaw approaches the stranger about becoming the town protector. After the stranger refuses, declaring that he is not a gunfighter and has nothing against the Carlins or Bridges, Shaw states that the three men stole gold from the mining company office and hid it under the floorboards of their shack. When the stranger still refuses, observing that the theft story sounds like a set-up to him, Shaw explains that he was unwillingly appointed sheriff after Marshal Jim Duncan was whipped to death in the street. Stopping in his tracks, the stranger asks why anyone would do that, then finally accepts the job after the sheriff agrees to give him anything he wants. Starting off by presenting some Indians with a pile of blankets from the dry goods shop, the stranger next goes to the leather shop, where he appropriates three pairs of new boots, a gun belt and saddle. He then pulls the sheriff’s badge from Shaw’s vest and pins it onto Mordecai’s shirt, making Mordecai swell with his new title and power. The stranger then informs the townsmen that they will serve in his newly formed militia. As the stranger drills the townsmen in target practice and positions them on the rooftops to act as snipers, the Carlins and Bridges are released from prison. Striking out for Lago on foot, they come across three men camping, then shoot them down and steal their horses. Meanwhile, the disgruntled townsfolk begin to turn on one another as they question the decision to give the stranger carte blanche. Annoyed by Mordecai’s pomposity over his newly appointed position, Lewis pushes him down, and he tumbles under a porch where he recalls the night that Duncan was whipped to death: As Mordecai watches in horror and Sarah Belding, Lewis’ wife, tries to stop the whipping, the town preacher, Callie and the rest of the town watch passively as the Carlins and Bridges lash the marshal to death. Later, the stranger goes to Callie’s room where he invites her to join him for dinner. After first rebuffing him, she relents, offering to meet him in half an hour. Following dinner, Callie and the stranger retire to his room to have sex, and once he falls asleep, Callie slips out while Morgan leads several thugs up the hotel stairs to kill the stranger. Bursting into his room, the thugs slam blocks of wood onto the bed, thinking that the stranger is asleep. Having anticipated the attack, the stranger had gotten out of bed and had been waiting outside to throw a stick of dynamite into the room, blowing up the hotel. As his assailants flee, the stranger shoots them all down, wounding Morgan, who mounts his horse and flees, leaving Callie behind. The stranger orders the townsfolk to bury the dead, then requisitions the Beldings’ room, the only undamaged room in the hotel. Grabbing Sarah, the stranger pulls her into the room with him, and when she tries to defend herself with a pair of scissors, he climbs into bed and goes to sleep. Insulted, Sarah jumps on him, and when he kisses her, she surrenders. The next morning, Sarah asks if he has ever heard of Jim Duncan, the town marshal who lies in an unmarked grave, adding that the dead do not rest without a marker. Once the townsfolk finish burying the corpses from the night before, the stranger paints “Hell” over the Lago town sign, then orders that the town be painted red. Later, Lewis tells Sarah to come to a meeting about the stranger, but she refuses, stating that the town was responsible for Duncan’s murder. Lewis tries to justify the murder by reminding her that Duncan had discovered that the mine was on government property and was determined to turn them in, an act that would have shut down the mine and thus the town. Unmoved, Sarah announces that she is leaving him and the town. Meanwhile, on the outskirts of Lago, the wounded Morgan crosses paths with Bridges and the Carlins. Morgan asks for help, but when Bridges demands the combination of the office safe in return for saving his life, Morgan refuses. Angered, Bridges plunges a stick into Morgan’s neck, killing him. The stranger, who had been trailing Morgan, witnesses the incident from the hills above and starts shooting at them. Once they take cover in the hills, the stranger ignites a stick of dynamite on top of a pile of rocks, sending a shower of rocks falling down on them, making Bridges realize that their assailant is just toying with them. After throwing several more sticks of dynamite, the stranger returns to Lago, which is now painted red, announces that the outlaws are coming and instructs the townsfolk to string up a banner reading “welcome home boys.” The men then take their positions on the rooftops, and as the bell rings, sounding the arrival of the outlaws, the stranger mounts up and rides out of town, leaving the baffled townsfolk behind. Charging into town, their guns blazing, the outlaws lasso the sheriff, shoot down the snipers and kill Dave as he tries to abscond with the gold from the mining company. After Lewis surrenders, the outlaws set the town on fire, then sequester the remaining townsfolk in the saloon. When Callie professes her undying love for Bridges, he sneers at her, then sends Cole to get their horses. Just as Dan demands to know who ambushed them, a bullwhip snakes around his neck and tugs him out the saloon door and onto the street, where the stranger, silhouetted against the red flames, whips him to death, then tosses down the whip. As the sound of flames crackle in the background, Bridges orders everyone out of the saloon, and once the crowd assembles in the street, the stranger throws a stick of dynamite, scattering them. Cole is running for his life when a whip lashes out and encircles his neck, hauling him off the ground. After Bridges watches in horror as Cole is strangled to death by the whip, the stranger guns down Bridges, who gasps, “who are you” as he falls. Lewis is about to shoot the stranger when Mordecai, wearing a big grin, guns him down. The next day, as the stranger rides through the burnt-out town, Sarah smiles, then climbs into her wagon and leaves. Passing through the graveyard, the stranger sees that Mordecai is making a grave marker reading “Marshal Jim Duncan, rest in peace.” When Mordecai remarks that he does not know the stranger’s name, the stranger replies, “yes you do,” and rides off into the distance.