This is an uncredited film version of Dashiell Hammett's novel "Red Harvest", which, has never been officially filmed. It is about a detective who comes to a small city and pits both sides in a gang war against each other until both are almost completely wiped out. The scenes where Toshirô Mifune's character is held and beaten, however, was taken from Hammett's novel "The Glass Key", which has been adapted for the screen twice.
Akira Kurosawa told Toshirô Mifune that his character was like a wolf or a dog and told Tatsuya Nakadai that his character was like a snake. Inspired by this direction, Mifune came up with Sanjuro's trademark shoulder twitch, similar to the way a dog or wolf tries to get off fleas.
Akira Kurosawa asked his sound engineer Ichirô Minawa to come up with a sound effect to be used when a sword is cutting, and killing, someone. After testing out slicing a sword into beef and pork, he finally found the perfect sample--putting two wooden chopsticks inside a raw chicken, then hacking it with a sword.
Akira Kurosawa challenged his assistant directors to come up with an image for the film to let Sanjuro know he was entering a bad town. He shot down all of their ideas, since all of them had already been done. Kurosawa himself then came up with the idea of the dog carrying the human hand.
Masaru Sato was instructed by Akira Kurosawa to write "whatever you like" so long as it was not the usual period samurai film music so commonly used by all the major studios at the time. He ended up writing something that was inspired by one of his idols, Henry Mancini, whom he had the pleasure of meeting shortly after the film was released, where they discussed his "Yojimbo" soundtrack.
Sergio Leone was inspired by this film and made the famous "spaghetti western" A Fistful of Dollars (1964) with a similar plot. However, because Leone did not officially get permission to remake this film, which was copyrighted, Akira Kurosawa sued him.
In one scene the samurai shows incredible skill at knife-throwing by impaling a blowing leaf against a wooden floor. This was accomplished by running the shot backwards. In the frame before the knife hits the leaf, you can see a slit in the leaf the same size and at the exact point where the knife penetrates it a frame later.
Yojimbo was an obvious inspiration for Sergio Leone's classic For a Fistful of Dollars (1964) although it was not credited as the source material for the film. Walter Hill however also remade Yojimbo years later as Last Man Standing (1996) starring Bruce Willis, and credited Kurosawa's film as the original source. All three films follow a very similar plot although each takes place in a far different setting and time in human history.
After Akira Kurosawa scolded Toshirô Mifune for arriving late to the set one morning, Mifune made it a point to be ready on set at 6:00 AM every day in full makeup and costume for the rest of the film's shooting schedule.
The fact that the main villain sports a gun shows the slow creep of Westernization and pitches the film as roughly taking place in the 1860s. It was around about this time that the USA started forcing Japan to come out of its isolationist policy that had effectively kept the country stalled in a feudal, almost medieval society.
When asked his name, the samurai calls himself "Kuwabatake Sanjuro", which he seems to make up while looking at a mulberry field by the town. Thus, the character can be viewed as an early example of the "Man with No Name".
This was a deliberate attempt by Akira Kurosawa to revise the cinema's attitude towards onscreen violence. He wanted to show the damaging effect of violence, rather than the slightly anodyne way that it had usually been depicted before. (He would later come to regret this move, as it spawned a mass movement in international cinema that hasn't abated even today.)
Akira Kurosawa was heavily influenced by the American Western for this film, particularly High Noon (1952) and Shane (1953). He also admitted to being heavily influenced by the film noir The Glass Key (1942).
Akira Kurosawa: [weather] Like in most Kurosawa films, rainy weather is present in a few scenes, increasing the effect of the characters' discomfort. The windy weather all throughout the film represents the chaotic life in the town.
The trivia item below may give away important plot points.
The massive amount of dust seen being blown about was actually imported by the truckload from an abandoned firing range. When the wind machines started, it was nearly impossible for the actors to keep their eyes open because they were being engulfed in the dust. When Tatsuya Nakadai was shooting his death scene, over the course of three days, the combination of the fake blood and the blowing dust made him break out in hives that lasted for weeks after filming.