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.
- "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 Kazemakase 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.
- 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.
- 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. Although 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.
- 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.
- Djurado is this to a tee, complete with the hero getting caught and beaten up.
- 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. Hilarity Ensues.
- 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 Corrupt Hick 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 townfolk 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.
- 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.
- 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, accidentally triggered one of these situations through domino-effect killings (he shoots at Gang A, who retaliates against Gang B, who retaliates back, people get caught in the crossfire... repeat until about 150 people are dead) after his young son was murdered by gangsters. By the time the crew catches up with him, he has been very clearly driven insane from the guilt 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.
- 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.