Bandits discuss raiding a mountain village, but their chief decides to wait until after the harvest inasmuch as they had raided it fairly recently. The plan is inadvertently overheard by a farmer, whereupon the villagers ask Gisaku, the village elder and miller, for advice. He states that he once saw a village that had hired samurai had remain untouched by raiders, and declares they should hire samurai to defend themselves. Since they have no money, Gisaku advises them to find hungry samurai.
After having little success initially, the scouting group watches Kambei, an aging but experienced rōnin, rescue a young boy who had been taken hostage by a thief. A young samurai named Katsushirō asks to become Kambei's disciple. The villagers then ask for help, and after initial reluctance, Kambei agrees. He recruits his old friend Shichirōji and, with Katsushirō's assistance, three other samurai: the friendly, wily Gorobei; the good-willed Heihachi; and Kyūzō, a taciturn master swordsman whom Katsushirō regards with awe. Although inexperienced, Katsushirō is accepted because time is short. Kikuchiyo, a man who carries a family scroll that he claims proves he is a samurai (though the birth date on it is for a young child), follows the group despite attempts to drive him away.
On arrival, the samurai find the villagers cowering in their homes, refusing to greet them. Feeling insulted by such a cold reception, Kikuchiyo rings the village alarm bell, prompting the villagers to come out of hiding. The samurai are both pleased and amused by this, and accept him as a comrade-in-arms. Slowly the samurai and farmers begin to trust each other as they train together. Katsushirō forms a relationship with Shino, a farmer's daughter, who had been masquerading as a boy for protection from the supposedly lustful samurai. However, the six samurai are angered when Kikuchiyo brings them armor and weapons, which the villagers most likely acquired by killing injured or dying samurai. Kikuchiyo retorts that samurai are responsible for battles, raids, taxation and forced labor that devastate the villagers' lives. By so doing, he reveals his origin as an orphaned farmer's son. The samurais' anger turns to shame.
Three bandit scouts are spotted. Two are killed, while another reveals the location of their camp. Against the wishes of the samurai, the villagers kill the prisoner. The samurai burn down the bandits' camp in a pre-emptive strike. Rikichi, a troubled villager who helps the samurai, breaks down when he sees his wife, who had apparently been kidnapped and made a concubine in a previous raid. On seeing Rikichi, she walks back into her burning hut. Heihachi is killed trying to save Rikichi, whose grief is compounded.
When the bandits finally attack, they are confounded by new fortifications, including a moat and wooden fence. Several bandits are killed according to Kambei's plan: The bandits are allowed to enter the village singly, to be hunted down and killed by groups of farmers armed with bamboo spears. Gisaku refuses to abandon his mill on the outskirts of the village and perishes with his family, who tried to save him. A lone baby is rescued by Kikuchiyo, who breaks down in tears, as it reminds him of his own childhood.
The bandits possess three Japanese matchlock firearms. Kyūzō ventures out alone and returns with one. An envious Kikuchiyo abandons his post—and his contingent of farmers—to bring back another. He is chastised by Kambei because, while he was gone, the bandits killed some of his farmers. The bandits attack again, and Gorobei is slain. That night, Kambei predicts that, due to their dwindling numbers, the bandits will make one last all-out attack. Meanwhile, Katsushirō and Shino's relationship is discovered by her father. He hits her until Kambei and the villagers intervene. Shichirōji calms everyone down by saying the couple should be forgiven because they are young and that before any battle, passions can run high.
The next morning in a torrential downpour, Kambei orders that the remaining thirteen bandits be allowed into the village. As the battle winds down, their leader, armed with a gun, enters the women's hut, from where he shoots Kyūzō. An enraged Kikuchiyo charges the hut; he is shot, but kills the bandit chief before dying.
The three surviving samurai watch as the joyful villagers sing whilst planting their crops. Kambei—standing beneath the funeral mounds of their four comrades—reflects that it is another pyrrhic victory for the samurai: "In the end we lost this battle too. The victory belongs to the farmers, not to us."