A Stranger (who looks like Number Six) rides across the Old West. He goes into the office of the territorial Marshall and resigns his position as sheriff, giving up his gun. The Stranger then starts walking, only for the thugs to ambush him. They haul him into the nearby town of Harmony and dump him into the town square. The Stranger wakes up and a Mexican welcomes him to town and directs him to the local saloon. The Stranger goes in and makes the acquaintance of the barmaid, Kathy. He reaches for a drink only to have it shot off the bar by the Kid, a youthful gunslinger. The Kid works for the Judge, the authority in town. He invites the Stranger over and asks why he gave up his gun and his badge. The Stranger refuses to say why, insisting his reasons are his own. The Judge offers him a job but he refuses, raising the Judge's suspicions.
The Stranger tries to purchase a horse but finds the horse dealer uncooperative. The townspeople approach him and ask why he isn't interested in staying in town. When he dismisses them, they take offense and start to riot. The Judge's men take the Stranger to the local jail. When he again refuses the Judge's job offer, they put him under "protective custody" on the Judge's orders. The Judge then orders the other prisoner to be taken out into the street to be hanged. The townsfolk gleefully prepare to string him up but Kathy intervenes: the man is her brother. They pull her away and her brother is executed.
The Kid is in charge of watching the prisoners and drinks heavily on the job. He practises his quick draw on the Stranger, who ignores him. Later, Kathy brings a bottle to the Kid and flirts with him, and promises to see him later. He's unaware that she's managed to grab the keys. After she leaves, she circles around the back and slips the Stranger the keys through the barred windows. Once the Kid passes out, the Stranger escapes his cell and steals a horse. Kathy brings him his gun and tells him how to escape.
The Judge discovers the prisoner is missing and slaps the Kid, who barely keeps his temper restrained. Meanwhile, the Judge's men are watching the borders and easily recapture the Stranger as he attempts to escape. They take him to the saloon where the Judge begins a trial against Kathy, for helping a prisoner to escape. The Stranger was under protective custody, and there are no charges against him. The jury quickly find her guilty and she's taken to jail. The Judge then offers the Stranger a deal: if he takes the position of Sheriff, Kathy goes free. The Stranger considers the deal and the Kid comes in and nicks him with several expertly-placed shots. The Stranger refuses to respond physically but taunts the Kid, and the Judge is forced to call his man off. When the Judge tells the Kid to watch Kathy, then hints that something could happen to Kathy under his care, the Stranger gives in and takes the position of sherif - but refuses to carry a gun.
The Stranger patrols the town and some of the thugs jump him. After a protracted fight, the Stranger defeats them. Battered, he goes back to the jail where Kathy warns him that they'll him eventually, just like they did her brother. She goes back to the saloon where the Kid watches her. When one man, Will, flirts with her, he shoves the man aside. Will draws his gun but refuses to fire, and the Kid casually kills him. The Stranger hears the gunshots and arrives, but the Judge's men say the Kid drew in self-defence. The townsfolk are angry at the Stranger for not doing anything. They send a representative, Jim, to ask the Stranger to help clean up the town and dispose of the Judge and his men. The Stranger is skeptical despite the fact the townspeople want to help. When Jim gets back to the saloon, the Judge demands to know what was said. When Jim refuses to talk, the Judge has his men beat him to death then drop him off at the jail.
The Stranger still refuses to put on his gun and goes to tell Kathy that he's leaving tonight and taking her with him. He tells her to meet him later that night. The Judge, seeing them together, decides to tell the Kid. While the Stranger rides out of town and disposes of the guards, the Kid confronts Kathy at the saloon. When he tries to molest her, she fights back and he strangles her to death.
The Stranger returns to find Harmony and sees the Kid leave the saloon. He finds her corpse and buries it, then puts on his gun… and resigns as sheriff. He finds the Kid waiting outside for him. They draw, and the Stranger wins. He then goes to see the Judge, who congratulates him but tells the Stranger he still has Kathy sot eh Stranger has to remain sheriff. The Stranger informs the Judge that Kathy is dead, and the Judge lets slip he prodded the Kid into going after Kathy, but only to rough her up. When the Stranger prepares to leave, the Judge warns that he'd rather see him dead than working for someone else. The Stranger draws on the Judge's three thugs and kills them, but the Judge guns him down from behind…
… and Number Six wakes up in the saloon. He's wearing his Village clothing and has a radio headset. Running out, he discovers that the people and horses are cardboard stand-up figures. Running down the street, he realizes that he is in a model town next to the Village. Going to the Green Dome, he confronts the Judge (Number Two), the Kid (Number Eight), and Kathy (Number Twenty-Two). Number Eight's scheme involved isolating Number Six and using drugs to confuse his sense of reality, then give and take away love, then force him to kill. He blames Number Two for the failure of the plan, as he lost control and "shot" Number Six. Number Six leaves, angry, and Number Twenty-Two starts crying and runs out.
Number Twenty-Two goes to the mock town and enters the saloon. Number Eight is waiting for him, and starts acting like the Kid. When "Kathy" scorns him again, he strangles her and screams in rage. Number Six hers the scream and comes running, and knocks Number Eight down. Number Two arrives and they look on as Number Eight, fully in his Kid persona, climbs to the balcony and then throws himself to his death.