A Mexican village is periodically raided for food and supplies by bandits led by Calvera (Eli Wallach). As he and his men rode away from their latest visit, Calvera had promised to return for more booty and loot the village again.
Taking what meager goods they have, the village leaders ride to a town just inside the American border hoping to barter for weapons to defend themselves. While there, they encounter veteran gunslinger, Chris (Yul Brynner); after listening to their tale, Chris suggests that the village hire more gunfighters as they would be cheaper than guns and ammunition.
The village men relentlessly try to convince Chris to be their gunman; while at first he agrees just to help them find men, eventually he decides to help them out in person as well as finding six other men to join them, despite the poor pay offered.
The other men include hotheaded, inexperienced Chico (Horst Buchholz); Chris’s friend Harry Luck (Brad Dexter) who believes Chris is seeking treasure; the drifter Vin (Steve McQueen), who has gone broke after a round of gambling; Bernardo O’Reilly (Charles Bronson), a gunfighter of Irish-Mexican heritage; cowboy Britt (James Coburn); and an on-the-run gunman Lee (Robert Vaughn), who is in the midst of a crisis of confidence.
The group recognizes they will be outnumbered, but hope that when Calvera realizes that the village has brought them aboard, he will move on to a different village.
Arriving at the village, the seven begin to train the villagers how to defend themselves. They all find themselves bonding with the villagers, sharing the meal the women of the village have made them when they discover that the villagers have little food themselves. Chico is fascinated by Petra, one of the village’s young women, while Bernardo begins to bond with three of the village’s little boys. Lee, meanwhile, struggles with nightmares and fears the loss of his skills.
Calvera and his bandits soon arrive, sustain heavy losses, and are run out of town by the gunmen and the villagers working in concert. Chico, who is Mexican, follows Calvera back to his camp, pretending to be one of the gang of bandits. There he learns that Calvera plans to return and raid the village because he is desperate for the food in order to feed his men.
Chico reports this back to Chris and the rest of the men. Though a part of the group believes they should leave, Chris insists that they stay and they ride out to make a surprise raid on Calvera’s camp. However, they find the camp empty and, on returning to the village, they find that the fearful villagers allowed Calvera to take control. Calvera spares the gunmen’s lives, believing they have learned the lesson that the simple farmers are not worth fighting for. Calvera also fears reprisals from the U.S. Army. The seven are curtly escorted out of the village. The group debates their next move and all but Harry agree to return and free the village from Calvera. Harry believes the effort will lead to their deaths and rides off alone.
A gunfight breaks out, and the villagers, recognizing the courage of the gunmen, soon join in the fight. Bernardo is killed protecting the children he had befriended, and both Britt and Lee die after killing a considerable number of bandits. Harry, who had a change of heart, arrives in time to protect Chris but is fatally shot. Soon, the bandits are routed, and Chris shoots Calvera. Calvera, in his dying breath, asks why men like Chris came back to protect such a small village.
The three remaining gunmen help to bury their own and the villagers’ dead. Chico announces he will be staying with Petra, while Chris and Vin begin to ride out.
The village elder bids them farewell and comments that it is only the villagers who have really won: “You’re like the wind, blowing over the land and…passing on;… ¡Vaya con Dios!” However, as they leave and pass the graves of their fallen comrades, Chris fatalistically observes, “The Old Man was right. Only the farmers won. We lost. We always lose.”