Yojimbo begins with a master less samurai, also known as a ronin, wandering the Japanese countryside. The ronin stops near a farmhouse and overhears a couple lament about their only son whose has given up the farming life in order to join a group of thugs working in a nearby town that is involved in a brutal gang war. Sensing an opportunity, the ronin heads for the town and encounters a dog walking through town with a human hand in its mouth. Undeterred, the ronin meets the local tavern owner who explains the sides to the samurai.
One side is led by Seibei, who is supported by the silk merchant and the ineffective major. The other side is led by Ushitora, who is supported by the local sake brewer. The tavern owner tells the ronin that he should leave town, but the samurai states that he intends to stay and implies that the town would be better off with both sides dead.
The ronin first seeks to sell his skills to Seibei, who appears to be the weaker of the two parties. Seibei is interested in the samurai’s service as a yojimbo, or bodyguard. With the addition of the ronin, Seibei feels emboldened and wishes to start an attack on Ushitora. But the ronin refuses to participate in the attack and returns Seibei’s payment after he overhears Seibei’s wife order her son to kill the ronin after the attack. Already committed to the attack, Seibei intends to continue on until the potential clash in interrupted by the arrival of the local government official. Both warring sides work hard to but on the appearance that the town is peaceful.
The town remains peaceful while the government official is in town, but he is soon called away when word is received that another government employee is killed in a nearby town. The ronin eventually learns that it was two assassins hired by Ushitora who killed the government employee. The ronin captures the two assassins after they nearly drink themselves into oblivion on sake. The samurai sells the two men to Seibei, so that he may use their statements as proof to take down Ushitora.
However, the ronin then tells Ushitora that Seibei’s men captured the assassins, forcing the gang lord to kidnap Seibei’s son and hold him for ransom. Ushitora is grateful for the ronin’s information and rewards him. At the prisoner exchange, Ushitora double crosses Seibei when Ushitora keeps Seibei’s son and has his brother shoot the two assassins. But the double cross was expected, and Seibei reveals that he has Ushitora’s woman, and he will exchange her the next day for his son.
The ronin learns that the woman is the wife of a local farmer who lost her to Ushitora over a gambling debt, who then gave her away as chattel to the town’s powerful residents in order to gain their support. The samurai hatches a plan to save the woman and return her to her husband and son. The ronin tells Ushitora that Seibei is on the way to kidnap her from her secret hideaway.
While Ushitora rallies his men, the ronin kills all six guards at the hideout. He then reunites the woman with her husband and young son, tells them to leave town, and gives them the money that Ushitora paid him the night before. However, Ushitora’s gun toting brother becomes suspicious of the ronin. Eventually, the ronin’s duplicity is discovered when Ushitora’s brother discovers a thank you note addressed to the ronin from the reunited family. The ronin is captured and beaten severely in the hopes that the samurai will reveal where the family is.
Ultimately, the ronin is able to escape Ushitora’s headquarters, and with the help of the tavern owner, he is able to get out of town in order to recuperate from his injuries. Once Ushitora learns of the samurai’s escape, he attacks Seibei’s whorehouse in order to find the ronin and wipes out Seibei’s entire clan.
While the ronin recuperates in a cemetery, the tavern owner is captured by Ushitora’s men and tortured for information concerning the location of the samurai. Once the ronin hears of his savior’s capture, he returns to town and kills Ushitora and his men, including Ushitora’s gun wielding brother. He only spares the terrified son of the farmers from the beginning of the movie. The samurai checks on the condition of the tavern owner, and then turns and leaves town, his task having been accomplished.