In the 1970s, two issues of The Brave and the Bold featured Batman teaming up with The Joker to solve a crime. In #111, they worked together to solve the mass murder of an upstanding local family, which someone had sloppily tried to pin on the Joker. In the end, it turned out that the whole thing was an elaborate plot between the Joker and the killer to lure Batman into a Deathtrap. In #191, the Penguin is murdered and it looks like the Joker did it. When Batman catches up to him, he proves that he couldn't have done it. It is eventually revealed that the whole thing was a Faking the Dead by the Penguin, who used it to kidnap a local cardinal.
At the end of Final Crisis, Superman is facing the Female Furies and the Justifiers. Who saves him and reverses the Anti-Life Equation? Lex Luthor and Dr. Sivana.
Lex:"Not a single word, Superman. We'll call this the Historic First Team-Up of the forces of "Good" and the forces of "Bad". And I'll take the credit for the win" Superman:"Whatever you say, Lex. Whatever you say."
Superman and Lex Luthor are in conflict almost all the time, and loathe each other with a vengeance, but they share a near-fanatical adoration for and protectiveness of their home city of Metropolis. This has caused them to put aside their differences, abandon their other objectives, and team up to take down villains bent on destroying their beloved city more than once.
They've even saved the world together more than once. Lex ends up doing almost as much good as he does evil.
The Great Phantom Peril: During the final battle, Faora commands the Phantom Zoners to attack Superman. Neither of them likes being ordered around by her, but the Zoners hate Superman more than they despise Faora.
Faora Hu-Ul: "Hear me, males! Kill him where he stands!" Kru-El: "We're obeying Faora?" Dru-Zod: "Destroying Superman must not be our first priority!"
This was hardly the first or the last time that Darkseid pulled one of these. In Crisis on Infinite Earths, for example, he ended up being instrumental in finally defeating the Anti-Monitor (but making it very clear he was only doing it not to help the heroes or anything, but rather to ensure that the Anti-Monitor wouldn't destroy everything).
Darkseid did the same thing with Imperiex.
In the final issue of Paul Cornell's Knight And Squire, everyone in the British super-community teams up to take down The Joker. The heroes, the anti-heroes, the Harmless Villains and the killers like Death Dinosaur. He's just that much of a threat.
Forever Evil: Lex and his "Legion of Doom"-esque alliance fighting back against the larger, more encompassing threat the Crime Syndicate poses.
In The Multiversity, Superdoomsday wrecked havoc on several Earths, but because he and his fellow Overcorp stooge are the only champions of Earth-45, Harbinger is forced to summon them in the final battle alongside several superhero teams he had previously wronged. Members of the Earth-10 New Reichsmen and Freedom Fighters are likewise recruited. However, due to the sheer immensity of the conflict, these antagonistic groups have little opportunity to lock horns.
In Year Five of Injustice: Gods Among Us, Batman recruits several supervillains to help him fight Superman's Regime, choosing them based on their adherence to a no-kill rule. After learning of Batman's plan, Superman does the exact same thing, though the villains he chooses are willing to use lethal force and are thus more numerous.
Jonah Hex: In #10 of the original series, el Papagayo forces Jonah to aid him in a plan to steal a store of gold from the Mexican government. When the the soldiers uncover the plot, they assume Jonah is a willing participant and Jonah is forced to fight alongside the outlaws to save his own life.
Wonder Woman (1987): Deathstroke unhesitatingly joins up with the heroes to fight Circe and her rather large collection of female villains gathered to hunt men, specifically superhero men, for sport in New York City.
X-Men: Magneto, always referred to as the Big Bad, is the first person the heroes team up with when someone worse comes along.
Particularly in the 90s cartoon, most notably in a season-long storyline in which he and Professor Xavier are stranded together in the Savage Land.
The brilliant X-Men graphic novel God Loves, Man Kills was the basis for X2, and thus follows the same plot except that, since the comics have been going on long enough that they didn't feel the need to hammer home his villainy, Magneto doesn't really have a Snap Back the way he does in the movie.
And in God Loves, Man Kills II, released to tie in with X2, the X-Men find themselves teaming up with the villain from the original.
Magneto has worked with the X-Men in multiple story lines, even becoming the leader in one story arc. This is because, for most writers, Magneto isn't as much a bad guy as he is a Well-Intentioned Extremist.
It wasn't just for one arc. In the late 1980s, due to Charles Xavier being absent, a reformed Magneto took over Xavier's School for Gifted Youngsters for something like four years (in real world time). If you were reading X-Men and New Mutants back then, Magneto as the head of the Xavier school felt like a new status quo.
When Nimrod the Super Sentinel started attacking everybody, the X-Men and the Hellfire Club had to work together to defeat him.
Loki is willing to fight on Thor's side pretty much any time Asgard is under attack; his goal is to rule it, after all, and he can't rule it if it's demolished. Also, in the Spider-Man comic "The Coming of Chaos", he was willing to team up with Spider-Man in order to save his mortal daughter, who had become possessed.
Spidey and Doc Ock ended up working together at one point, in order to deal with a new villain (Carlyle) who used Ock's arm technology to build a bank-robbing powersuit. While simply being robbed wouldn't have been enough to put Ock on the side of his mortal enemy, there was also the fact that Carlyle was threatening Ock's former fiancée, known to Spider-Man fans as "Aunt May". (Truthfully, Aunt May being endangered wasn't really a factor in the fight. It didn't do anything except surprise Doc Ock for a moment and lead to a very funny The Rocky Horror Picture Show joke. Spidey came into the fight late as Doc Ock was already going after Caryle for stealing his tech and trying to kill him. To Doc's credit, he DID stop a building from collapsing just long enough to allow the innocent civilians to escape at Spidey's prompting. That did nothing to STOP him from letting the building collapse on Spidey, noting "you are not a civilian". Doc Ock also wasn't happy about the inadvertent team-up, later noting (as he told Spidey the weakness in Caryle's armor), "I am not helping you — I am hurting him." World of difference.)
It wasn't even the first time Spidey and Ock teamed up, since they also set aside their differences when Hammerhead kidnapped Aunt May. Spider-Man wanted to rescue Aunt May because she was one of his loved ones (along with the fact that he was Spider-Man after all), while Doc Ock wanted to marry May so he could gain access to a nuclear power plant she had inherited.
Venom and Carnage hate each other far more than they hate Spider-Man. Any time Carnage pops up, Venom will call a truce with Spider-Man to go whale on Carnage. This most famously occurred in the storyline Maximum Carnage, which was adapted into a Sega Genesis and Super Nintendo game. Also, In the oddly-named "Venom vs Carnage" comic, after Carnage produces a new symbiote, he and Venom decide that, in the end, they hate the new symbiote even more than they hate each other (it's implied in Carnage's case that this is part of symbiote biology). The result? Their only teamup. Venom calls it "Temporary. VERY temporary."
In one of the most memorable stories of Inferno that didn't involve the mutant teams in the main storyline, Spidey fought alongside J. Jonah Jameson to defend The Daily Bugle against the invading demon horde. It was little wonder that the writers named the story "When the Bugle Blows!"
In the one shot comic Spider-Man Dead Man's Hand, Spidey and his old enemy the Tinkerer cooperated for mutual benefit after the third Carrion infected New Yorkers with a disease that made them zombie-like minions. (The Tinker was working on a teleportation device for the Enclave that Spidey needed to get to Wungadore quickly, as he knew the High Evolutionary might have inside information on the plague, and the Tinkerer was willing to help, seeing as his son was one of the victims of said plague.)
Spider-Woman called a truce with several former enemies to escape the clutches of the Locksmith in the 50th issue of her series, and even invited a few of them to her apartment later! (Unfortunately, said party was interrupted by the darker threat of the story.)
In Marvel's Secret Invasion mega-event, the villain mastermind The Hood sends his forces into battle to save the Earth from the Skrulls. He has his own reasons for this: it helps Norman Osborn in his ploy to take over SHIELD and instigate the Dark Reign. (It's also implied that The Hood had no idea of Osborn's plan, until he called together the Cabal for the first time. The Hood would have let the assembled forces fight the Skrulls, if not for the simple fact that if the Skrulls destroy the Earth, they destroy his business.)
After the death of the Human Torch, Doctor Doom and Reed Richards have very reluctantly agreed to work together in the Future Foundation. This arrangement was brokered by Reed's genius daughter Valeria who convinced Reed that the FF needed someone as ruthlessly pragmatic as Doom if they were going to save the world. She got Doom on board by promising to help undo the brain damage the Intelligensia inflicted on him in Fall of The Hulks.
Not the first time Doom has teamed up with his enemies. An early story arc had him actually leading the FF against the villain known as Over-Mind.
One What If? comic had Wolverine, Spider-Man, Hulk and Ghost Rider take up the mantle when the original FF were killed. When a villain nearly kills them too, Doom shows up and saves them, declaring that no one, save Doom, may defeat the Fantastic Four... Apparently including their replacements.
One story-arc has Cap teaming up with the Red Skull of all people in order to stop a resurrected Hitler from taking control of the Cosmic Cube. Incidentally, this would lead Cap to being briefly exiled from the United States, since the U.S. government assumed he had turned his back on America by aligning with the Skull.
Another time, Diamondback of the Serpent Society sought Cap out when the Viper (Madame Hydra) instigated a hostile takeover of the Society so she could use them to turn the population of Washington, D.C. into Snake People. The Captain and his allies helped Diamondback and other Society members still loyal to its founder, Sidewinder, in stopping Viper and reversing the effects of her snakeification of the Capital. This led to Diamondback's HeelFace Turn and Sidewinder's retirement.
Caleb Hammer and Gunhawk, both of whom were hunting Kid Colt, temporarily join forces with him to defend the town of Wonderment in Blaze Of Glory.
The Daken and X-23 crossover involved this. Daken was initially working with Malcolm Colcord, while playing all the other parties against one another in pursuit of his own goals. However once Colcord's intent to recreate Weapon X is revealed, Daken and Laura throw in together to bring him down. Unlike Daken's relationship with their father, the team-up results in them becoming Friendly Enemies when they realize they're Not So Different.
In Doctor Doom (2019), Doom and Kang cooperate briefly. They insult each other constantly, but respect each other's intent to kill the other at some point.
Infinity: A large number of nominal enemies — including the Kree, Skrull, and Shi'ar empires, as well as the Avengers — unite to counter the threat that the Builders pose to the whole universe.
Ratchet and Megatron teamed in an early episode to bring down Shockwave. Megatron, naturally enough, tried to betray Ratchet, but Ratchet was prepared.
Several years later, during the "Space Pirates!" story in the UK comic, the Autobots and Decepticons join forces to repel the Quintessons, who are trying to conquer Cybertron before Quintessa explodes. Ultra Magnus and Soundwave even get a Back-to-Back Badasses moment. At the end, Soundwave briefly considers the idea of a lasting peace, but realizes the two factions have come too far to ever resolve their differences.
The Autobots and Decepticons were forced to team up again against the Cybertronian Empire, a faction of hyperevolved Decepticons who had abandoned Cybertron eons ago to create a star-spanning empire of their own. They consider the Autobots and the original Decepticons to be disgusting savages, and eventually returned to destroy their "lesser" brethren.
Another storyline had Starscream come in contact with a cosmic power source called the Underbase, which made him so powerful - not to mention drove him to madness - that the Autobots and Decepticons were forced to team up to stop him. Notably, they were not able to - overdosing on the Underbase's power eventually destroyed Starscream.
Miles Morales makes an unexpected team-up with Rhino when he finds out that they are both following the same kidnappers. Also, Rhino may have had some fights with the original Spider-Man, but has no beef with this new one.
More recently, we've had a non-Freedom Fighters examples, as the Anti-Hero Babylon Rogues teamed up with their rivals the Battle Bird Armada to find their ancestral homeland of Babylon Gardens — ironically, this puts them in opposition to the Freedom Fighters, as the entrance to the Gardens is apparently in their home of New Mobotropolis.
The Post-Super Genesis Wave reality provides an interesting example in the case of the Midesta Freedom Fighters, and the local Egg Army Boss, Nephthys the Vulture. She's an old friend of theirs, who only joined Eggman for the sake of keeping his oppression to a minimum, with the Fighters going along with it and only putting up a facade of resistance, in order to keep the region stable and not draw too much attention from either side in the grander conflict. Notably, both groups see Sonic as more trouble than anything, as his fight with Eggman just brings the latter's heel down harder on his victims.
A funny example from the comic's early days has the Freedom Fighters, Original Robotnik, and Snively are captured by an alien named Khareem of Weet so he can study them as representatives of Mobian Life. Of course Robotnik offers a temporary alliance to escape, but the Freedom Fighters point out that they don't actually NEED him to escape and that he could only come with them if he agreed to become an official Freedom Fighter. Cue a panel of a teeth clenched Robotnik swearing to "protect Mobius from bald, egg-shaped lamoes with delusions of granduer."
Black Moon Chronicles: After Fratus Sinister is defeated by Lord Parsifal and has to go on the run, he joins up with the Black Moon to get revenge on both the emperor and on the dragonlords who abandoned him. Wismerhill even uses the trope word-for-word, stating that the enemy of his enemy is his friend.
In the comic book series ElfQuest, when two elf tribes — the Wolfriders and the newly-introduced Go-Backs — join forces to wage war against the trolls of King Guttlekraw, the elves form a grudging alliance with the trolls formerly led by the late King Greymung, who have been enslaved by Guttlekraw, even though Greymung's trolls have been the hated enemies of the Wolfriders ever since betraying them back at the start of the storyline. The Go-Backs, meanwhile, would never have thought of teaming up with trolls of any kind, period... But it's probably only because of this uneasy alliance that Guttlekraw's trolls are defeated.
Happens on a massive scale in the Farscape comic book arc "The War for the Uncharted Territories", when essentially all the factions in the Uncharted Territories have to put aside their rivalries and join forces in order to stand the slightest chance of defending against conquest by the Kkore, which up until then has been defeating everyone in Curb Stomp Battles.
The Three Amigos storyline in Judge Dredd is purely an excuse to team him up with his nemeses, Judge Death and Mean Machine Angel. The creators themselves considered this Villain Decay for Judge Death in particular (who's known mainly for killing everything in sight).
In Paperinik New Adventures, Paperinik or Pk (Donald Duck's superhero alter ego in the comics) is forced to work together with a notorious time pirate known as The Raider early on in order to save a large part of Duckburg from being destroyed. Later on, they actually find themselves in Enemy Mine situations so often that they build up a strange kind of friendship. The Pikappa reboot has a full story centered around this, with Donald teaming up with the Evronian Soldier Ekdon to take down a Starfish Alien, which the Evronians once planned to use as a Living Weapon against the Guardians of the Galaxy, being motivated in the bigger picture against the Imperial Adviser Gorthan (revealed to have been Bitter Rivals with Ekdon, having gotten rid of him to ascend in the Evronian Hierarchies. Lampshaded by the Hero near the end "The best ally is an enemy who has a score to settle with your own adversary".
The DC run of The Powerpuff Girls introduced the Micro-Puffs, three sprite avatars of the girls who show up to cause trouble. In "Micro-Managing" (issue #64), the Micro-Puffs brainwash Buttercup and Bubbles into thinking they should be the PPG leader (it doesn't work on Blossom since she's already the leader). Blossom gets help from Mojo Jojo, who counters with Mini-Micro Puffs who drive the Micro-Puffs absolutely crazy. (Mojo's motive for helping was because he didn't get a Micro-Mojo). It ends with Mojo and Blossom shaking hands in the pulsating hearts panel.
In The Smurfs comic book story "The Gambler Smurfs", the Smurfs' constant Big Bad Gargamel temporarily aligns himself with them to help save a forest from a count whose love of gambling leads him to turning the entire Smurf Forest into a gambling complex. After the crisis has been averted, Gargamel returns to his desire to capture the Smurfs.
In Sojourn, Arwyn and Gareth find an unlikely alliance with a dragon against Mordath.
In an Infinities (a what-if brand) issue of Star Wars, specifically the one taking place during the Mortis Arc of Star Wars: The Clone Wars, of all people, Yoda and Darth Sidious (the latter presumably having revealed his Sith identity to Yoda) had to forge a temporary alliance to stop Anakin Skywalker, who became exceptionally powerful via the Dark Side thanks to the Son. The allegiance did them no good, though, as Anakin effortlessly killed them.
Written long before that, Marvel Star Wars has some examples. In one comic Leia and one single stormtrooper from Alderaan are the only respective survivors of disaster on both sides; the stormtrooper claims to be taking her prisoner but by the time anyone finds them it's not the case anymore. In the World of Fire arc, Luke and Leia and a small party of Imperials team up to try and shut off a lethal planetary security system; here, it starts with the Imperials making a threat-offer, but the head of the group soon feels they're trustworthy and starts getting friendly, while one of his men plans to kill them.
Sonic the Hedgehog (IDW): Issue #25 sees the Metal Virus arc get hijacked, as the Deadly Six manage to take control of Eggman's resources and the Zombot horde. With no other choice if they want to survive, Eggman teams up with Sonic and the other heroes to steal the Chaos Emeralds back from the Zeti so they can be used to cure the plague. Furthermore, Amy also recruits the Babylon Rogues to help, who only agree out of pragmatism (since if the world gets completely overrun, they'll eventually run out of supplies and be infected too).
In IDW's Transformers comics, the threat of Thunderwing was bad enough for the Autobots and Decepticons to team up to try and stop him. Both times, in fact. And it still barely slows him down.
In Volume 2 of Redman, Redman is forced to team up with Telesdon and Beacon to defeat Birdon. It ends badly for the latter 2.
In "The Fallen, Part Two", Gabrielle Carlotti is sorely tempted to kill the injured Chakuun Cohort General on Theta Kalyb in revenge for the Chakuun destroying the New Milan colony. However, she can't bring herself to do it. The experience teaches the Cohort General that humans are not as primitive and savage as she believed while Gabrielle learns that the Chakuun attack planets which the Tholians consider part of their territory. When the Cohort General is rescued by her troops, she stops them from killing Gabrielle and calls off the attack on Theta Kalyb.
In "Nemesis", after being attacked by the Temazi, Captain Pike, Spock and Dr. Boyce are forced to cooperate with Commander Kaaj and Virka so that they can all escape the Temazi homeworld. Kaaj's motivation for helping is that he will not allow anyone to rob him of the chance of killing Pike.
The 'Dogs of War' arc for the Thundercats comic has Lion-O offer one of these to the Mutants and Mumm-Ra when the titular canines invade Third Earth. Of course things go awry when the bad guys betray their allies. Except they didn't, and it was Jackalman and Ma-Mutt who betrayed both groups to side with the War Dogs. Once freed, both Mumm-Ra and the Mutants are instrumental in taking down the invaders, with Mumm-Ra even opting for Bad Guys Do the Dirty Work when Lion-O tries to reason with the Dogs' Alpha.
Rick and Morty (Oni): To defeat Doofus Jerry, Rick is forced to call the aid of the Citadel of Ricks. Unfortunately, this still doesn't work, and Doofus Jerry just defeats all of them.
Issue 12 sees Zim and Dib accidentally slingshotted into a Bad Future where Zim has conquered the world. However, since the two Zims don't get along, the present day one teams up with Dib to defeat Emperor Zim and escape back to the past.
During the Battle Void arc, Dib teams up with the alternate Zims of the Zim Resistance to overthrow Zim Number 1 and escape the Zimvoid. And when it turns out that "Number 1" is really an insane alternate Dib who might accidentally destroy The Multiverse, all the loyalist Zims join the team up against him.
Disney Ducks Comic Universe: One story features the Beagle Boys hosting a family reunion where Beagles from the whole world will pick a rich target in Duckburg to rob. Scrooge McDuck, Flintheart Glomgoldnote He's South African but holds enough ventures in Duckburg to be a potential target and John D. Rockerduck set their differences aside to make a mutual defense pact since each one knows how to defeat the Beagle Boys the other billionaires never faced before. After being defeated, the other Beagle Boys team up with a rival criminal family for another raid at the Money Bin but it lasts less than five minutes because Glomgold and Rockerduck tricked them into thinking each family betrayed the other.
In Warlord of Mars, Linea offers to help the heroes in stopping her father, the mad high priest of Issus out to destroy life on the planet. She makes a point that she dislikes the Red Martians, and is only helping them to ensure a future for her people.