So you have a pair of bosses in one realm. They're both corrupt, and they both sell a certain type of goods (e.g. guns, alcoholic beverages, fabrics, etc.). The town they run is a virtual ghost town aside from their cronies. Then a lone warrior (usually a stranger) shows up, usually unprepared, and after learning about the situation in the town, he decides to eliminate both bosses and free the realm from their grip. This involves an elaborate spy game in which he masquerades as a member of one boss's gang and works behind the scenes to ensure that both gangs are completely annihilated.
Sometimes, there'll be a Damsel in Distress held prisoner (often due to a gambling debt) by the gang of which the lone warrior is a member. If that's the case, he'll eventually free her and send her (and, if present, her family) away with some money.
Note that for a conflict to qualify as this, the conflict already has to be underway by the time the lone warrior shows up. If he's the one who started the conflict in the first place, you may be looking for Playing Both Sides, of which it's a Sub-Trope.
Also a subtrope of Whole-Plot Reference, in this case to A Fistful of Dollars. Although this plot actually predates the film,* it's the one that's most directly imitated and referenced by later works. See The Expy With No Name, when it's the protagonist of A Fistful of Dollars that is copied by another work.
- Pokémon: The Original Series: "Showdown at Dark City" is pretty much Yojimbo... with Pokémon! And two rival gyms going too far with the Serious Business! And rated TV-Y7!
- Fist of the North Star had one such episode where two rival gangs are laying waste to the town. Ken's actions finally end in the two gang leaders unwillingly crushing each other to death via Pressure Point-enhanced Bear Hug. Ken has a rare Bond One-Liner at this point, saying they make a lovely couple.
- Subverted in Samurai Champloo and Carried by the Wind: Tsukikage Ran. Both have a basically Jidaigeki setting, and both also have episodes that seem to be shout outs, having the ronin protagonists come to a town occupied by rival gangs. However, in both works, one of the gangs is clearly the good guys (probably owing to the fact that in Yojimbo one was A Lighter Shade of Black), and the protagonist(s) takes their side.
- A storyline in Golden Kamuy has Hijikata Toshizou and Nagakura Shinpachi take on feuding criminal gangs in the spirit of this trope. Uniquely, they're some of the villains in the grander scheme of things, with their own agenda on the line.
- Kaze No Yojimbo: George Kodama arrives into a town divided by two rival syndicates and tracks. He's searching for a man called Araki Genzo and what happened to a missing railcar, and end up playing them.
- Dirty Pair visits this trope in the TV episode "Hire Us! Beautiful Bodyguards are a Better Deal", where the Lovely Angels each infiltrate one of the two gangs dominating a planet specializing in Green Rocks, disguised as rival gunwomen. Both gangs eventually get a tip who they are, and try to force them to duel to smoke them out, but the impromptu catfight they stage to buy time actually convinces them for long enough to get rescued by the Team Pets. The planet explodes while they're escaping the scene. It's not the Pair's fault, as usual.
- This is the plot of the Marvel Comics MAX Luke Cage series.
- Daredevil does this from time to time with the identity of a mysterious mob enforcer called "shades".
- Batman had an emergency plan to start a Gang War as Matches Malone and secretly manipulate it so as few people died as possible. Unfortunately, Stephanie Brown didn't realize Matches' key role in the plan when she set it in motion.
- The Punisher has been known to do this when his usual methods are too direct. However, at least once he did the opposite and secretly facilitated a massive peace conglomeration among mob families so the leaders would all eventually meet to negotiate and he could get them all at once in the same room.
- Torpedo once had Torpedo's Bumbling Sidekick be mistaken for a (competent) assassin and hired by a Jewish shopkeeper to kill his competitor. Rascal goes to see the guy, who offers him more money, goes to see the first, who offers him more... In the end, he drags them both out into the street to make up their minds. They have a fast-paced discussion in Yiddish, shake hands... and beat the crap out of Rascal.
- In the first issue of Wolfskin, Wolfskin comes to a Noi village, split between two feuding brothers who both want him to destroy the other. Wolfskin ends up killing everyone in the village.
- One story arc of the classic Star Wars comic Dark Times is an extended homage to Yojimbo, following a disgraced Jedi as he brings peace to a town torn apart by criminal gangs by turning the thugs against one another.
- Usagi Yojimbo once did a two man variation on this, where Usagi and his friend Gen, the Jerk with a Heart of Gold Bounty Hunter, tried to play two gangs in a town against each other, with each of them getting hired by a different gang and then meeting in secret to plan the downfall of the two gangs. It doesn't end as smoothly as usual; the leaders of the gangs get into a premature fight, both of them die, and their gangs scatter rather than face Gen and Usagi, but minutes after the two bosses die, an infamous Rōnin that one of the bosses had hired arrives in town, none too pleased to have come all this way without getting paid. To avoid a fight, Gen gives said ronin the money he took from his boss up front, believing that he and Usagi could still split the money Usagi was paid. Unfortunately the straight laced and honorable Usagi hadn't thought to demand payment in advance from the gang leader who "hired" him, so much to the chagrin of Gen, their only profit from the whole escapade is some food from the peasants and the gratitude of the common people.
- Recycled In Space with the Parody Fic A Fistful of Mammary Gland. Seven of Nine aka the Woman with No Name (just a number) arrives on Voyager to find the crew split into Maquis and Starfleet factions.
Seven had the strange feeling that this scenario had been played out before, like in parallel universes where the same events were repeated in endless variation. Like a story that had been ripped off by one film director after another. Like she'd drunk too much Talaxian hootch and her multivariate sensors were no longer coordinating their feedback.
- Yojimbo, the most popular of Akira Kurosawa's films, was chiefly inspired by a 1942 film adaptation of The Glass Key, though the plot more closely follows that of Red Harvest. Some of Buchanan Rides Alone may have been added to it, too.
- A Fistful of Dollars, the first of Sergio Leone's trilogy of Spaghetti Westerns featuring the Man with No Name, is the Trope Namer. Kurosawa sued Leone for plagiarizing Yojimbo and won, which is why this one wasn't released in the United States until three years after it was made; part of the settlement was that Kurosawa's company got the East Asian distribution rights for Fistful, which made him more money than most of his own movies.
- Django follows this plot. The title character arrives into a town run by a racist soldier who guns down peons for fun and a leader of a gang of Banditos, and plays them against each other. The twist is that Django and the leader of the bandit gang used to be partners.
- A Stranger In Town is one of many Spaghetti Westerns that followed this plotline.
- Cop or Hood has a Cowboy Cop (played by Jean-Paul Belmondo) engineering a Mob War between two Southern France gangs to rid the city of Nice of them.
- Djurado is this to a tee, complete with the hero getting caught and beaten up.
- The Magnificent Swordsman is Shaw Brothers' take on the Yojimbo formula, with the titular hero entering a town besieged by two bandit gangs.
- Last Man Standing, set during the Prohibition era. Unlike Fistful of Dollars, this one is an authorized remake of Yojimbo, even crediting the screenwriters of Yojimbo in its opening.
- Roadhouse Nights is a loose adaptation of Red Harvest from Paramount Pictures, coincidentally the same studio that adapted The Glass Key.
- Support Your Local Gunfighter, starring James Garner, is a parody about a gambler named Latigo who wanders into a jerkwater mining town led by, you guessed it, two mining bosses looking for gold. He pretends to be an enforcer for both sides.
- Karate Warriors sees Shinichi Chiba getting involved in a gang war in a plot that can basically be described as The Streetfighter meets Yojimbo.
- The Warrior and the Sorceress, which is more or less Yojimbo in space. Its star, David Carradine, went into a discussion with executive producer Roger Corman over this.
- Miller's Crossing, which is inspired chiefly by The Glass Key and is about a gang war that starts when one boss puts a bookie (who the other boss had put a hit on) under his protection, with The Dragon to the first boss (who, unusually for this trope, survives) Playing Both Sides.
- Lucky Number Slevin is this, but there's a Kansas City Shuffle involved to kill both rival gangs' bosses (if a lot of people even know what a Kansas City Shuffle is, it's probably because of this movie)... and it's pretty much all about revenge, rather than trying to find some kind of good in killing both sides.
- Sukiyaki Western Django is about a lone gunman who joins forces with a prostitute to take down the Genji and Heike gangs a few hundred years after the Genpei War. Bonus points for including a character called Piripero (the name of the cooper in Fistful of Dollars).
- Pretty much Shintaro Katsu's Zatoichi had this as his M.O. whenever he walked into a town with two oyabuns/gangs/corrupt officials. You could bet that by the end of the episode or movie they'd all be dead after Zatoichi had been playing them or they'd played him for a fool and the blind anma had exacted bloody vengeance on them and their underlings.
- The Jean-Claude Van Damme movie Desert Heat, with two feuding criminal families (one rocking the All Bikers are Hells Angels look and one which looks more like a Crazy Survivalist gang) and occurring deep in the New Mexico desert. JCVD's character is robbed of his Cool Bike (an Indian) and Left for Dead, and he goes One-Man Army on both sides-with some help of the local townsfolk on the final battle.
- Youth of the Beast: A former cop infiltrates a Yakuza gang to avenge their murder of his partner, and uses a rival gang in his plans.
- Death Wish 4: The Crackdown holds a variation, with Paul Kersey conducting raids on two rival drugs gangs in order to drive their leaders into meeting in neutral ground (so they can discuss who is doing this in the hopes of preventing a gang war) and thus kill them all.
- Mad Max: Beyond Thunderdome opens this way, with Max arrives in the post-apocalyptic Wretched Hive of Bartertown, and getting roped into the feud between Aunty (the settlement's ostensible leader) and Master Blaster (a duo who control the lucrative pig farms that keep the town fed and fueled). Unlike most examples of the trope, however, Max is not one step ahead and is basically operating by the skin of his teeth the entire movie. At the end, Aunty basically wins, although Max is able to help Master escape.
- Omega Doom, a cult-classic 1996 American science fiction action film directed by Albert Pyun and starring Rutger Hauer, is almost entirely based on this premise, set in a distant future after a Robot War where humanity lost and older and newer robots are going at it, with Rutger Hauer as a cyborg leftover from the war and caught in the middle.
- What Could Have Been example: Eminem was attached, in the early 2010s, to a Development Hell movie called Random Acts Of Violence (no relationship to the slasher movie from the late 2010s) which would have had this plot, being about a highly intelligent ex-con playing off his former criminal gang and the FBI agents forcing him to wear a wire.
- Red Harvest (the Trope Maker) and The Glass Key, both written by Dashiell Hammett. Both feature a detective who starts out as a pawn in a turf war between rival gangs but who quickly finds a way to leverage the situation to his own advantage (and his would-be controllers' dismay).
- The Sharp End, written by David Drake. Drake himself confessed to cribbing the plot from Red Harvest.
- Jack Reacher: In Blue Moon, Reacher goes to a city divided between rival Albanian and Ukrainian gangs and takes out two Albanian loan sharks harassing his new friends. The Albanians assume the Ukrainians did it and retaliate, leading to an escalating chain of retaliatory killings. Reacher is initially oblivious to the mob war but sets out to decapitate the leadership of both gangs by the second half of the book.
- Jhegaala was referred to in one review as "Steven Brust doing Red Harvest". The critic would be pretty much accurate in his assessment. The plot involves ex-assassin Vlad Taltos returning to his hometown and finding it wracked with corruption and caught between a corrupt merchants guild and a "guild" of witches. Vlad naturally plays the two against each other.
- Another potential subversion: Red Country (a fantasy Western) has the protagonists go to a "town" that is being fought over by two rival saloon owners/brothel keepers and they fight on the side of the one that they interpret (possibly incorrectly) as the good guy.
- One killer in NUMB3RS started doing this to try and eliminate gangs after his young son was murdered by gangsters; he would kill a member of one gang and make it look like the rival gang did it, so the victim's gang would retaliate against said rival, who retaliates back, and so on, often with 5 or 6 shootings at least stemming from that one murder. By the time the crew catches up with him, his actions have resulted in the deaths of about 150 people (including an undercover cop and some relatively blameless novice gangbangers) and he very clearly has gone insane from the guilt and grief and winds up killing himself with his handgun.
- The Second Doctor Doctor Who story "The Highlanders", in which the Doctor accidentally gets caught up in war between the Jacobites and the English, poses as a German and has a lovely time playing both sides off against each other by selling them fabricated information.
- The Discworld Roleplaying Game spaghetti western setting "A Fistful of Dwarfs" naturally includes this as a scenario, featuring The Dwarf With No Name.
- Borderlands 2: The "Clan War" chain of sidequests involves doing various unsavory things (from sabotage and theft to crashing a wake) to provoke a showdown between two Feuding Families, the Zafords (who are basically The Irish Mob transplanted to Pandora) and the Hodunks (who are redneck/hillbilly-flavored bandits). Lampshaded at one point when Ellie (the quest giver) tells you "You could be the last man standing with a fistful of dollars... yo, jimbo!"
- In the original Knights of the Old Republic, when you arrive to the Sith Academy world Korriban, you find yourself drawn into a power play between two top instructors, vying for control over the Academy. While you can support either of them, the most satisfying resolution is to let them both think of yourself as their double agent and ultimately triple-cross them into destroying each other.
- Far Cry 2 has the player manipulate both sides in a civil war to get information on The Jackal so he can kill him. In the end, both sides pull an Enemy Mine and the player winds up working for The Jackal to kill the leaders of both sides.
- Way of the Samurai has this as one of its plot routes, which is unsurprising given that Yojimbo is a major influence on the game.
- Red Dead Redemption II has a variation where the outlaw protagonists get mixed up in the feud between the Grays and the Braithwaites - powerful plantation-owning families in the Deep South town of Rhodes - mostly because they figure there could be a lot of money in it somewhere, rather than for any noble purpose of ridding the town of their influence. The player character, Arthur, also gets roped into serving as a go-between for a pair of Star-Crossed Lovers on opposite sides of the feud, which he sardonically calls "an inbred retelling of Romeo and Juliet." As the stakes escalate, however, it becomes clear that the Braithwaites, at least, are really bad, and the gang develop a personal reason to want to get rid of them.
- Parodied/subverted in the The Order of the Stick bonus strip "Uncivil Servant", which shows an incident from the backstory of Heroic Comedic Sociopath and Token Evil Teammate Belkar Bitterleaf. Belkar arrives in a town and sees men from two rival organizations demanding money from a shopkeeper. Both of them see Belkar slay a giant bug and each wants them on their side, because of his skills. Belkar ends up killing them both, and does a Shout-Out to Toshiro Mifune as he does so. However, in a darkly humorous Tomato Surprise, it turns out that Belkar misread the situation and killed innocent people — the two guys weren't gangsters, but a policeman and a fireman each seeking donations for their organizations. The two organizations also have a volleyball game for charity coming up, and each wanted Belkar because of his jumping skills.