If this is the case, it's an Ambiguous Side Turn.
This is when someone doesn't waver from black to white and back, but from gray to grey. We know the position's changed, but how so? Is he good or evil? Gone from good to a different kind of good? It's hard to tell because everyone in the piece wavers.
To be clear, the characters and readers know which side the turner is on (or at least which party he joined). It's about the readers not knowing if his turn was towards good or towards bad, because they don't know if the party he joined is good or bad. The other characters in the show will usually describe it as a HeelFace Turn if he joined their group and as a FaceHeel Turn if he joined their enemies, because most people will consider their own group the good side and the other side the bad side. In such cases, a character's true moral compass alignment is generally revealed more by the motive and means of their defection than by the act of defecting itself.
Keep in mind that this trope is about a change of sides, not about characters. It's not enough for a character to have an ambiguous alignment, he must also actively change sides from one ambiguous group to another (or from one good / bad group to another, as long as you can't tell which one of the two is better).
Often revealed to be a FaceHeel Turn or a HeelFace Turn as people's motivations become better revealed. Often done by an Enigmatic Minion, Ensemble Dark Horse, or a Wild Card. See also Hazy Face Turn, where the universe has defined good and evil, but a character switches sides.
Unmarked Spoilers Ahead, for obvious reasons.
- Happens a fair amount in Code Geass, especially with Suzaku.
- In InuYasha, Sesshomaru is a stoic antagonist to Inuyasha who doesn't hate his younger brother, but wants to kill him for personal reasons. Once Naraku teams up with Sesshomaru and almost immediately betrays him, and the latter is tended to by Rin, he more or less switches from Inuyasha's amoral antagonist into a lesser evil who is much more interested in killing Naraku. Spends most of the manga not officially allied to Inuyasha because he's too busy just passing through. This changes after Magatsuhi enters the storyline. From that point on, he's much more open about helping and even protecting Inuyasha's group.
- The nature of One Piece allows this trope to occur aplenty:
- X. Drake was formerly a rear-admiral of the Marines before he turned pirate. While there is no doubting that pirates are generally considered menaces by most of the populace, the corrupted World Government and the Marines have been shown to be just as cruel, making the nature of this change quite hazy indeed.
- Pirate Jango went from pirate to marine. Unlike the above example, this is probably a closer to a HeelFace Turn considering it was The Power of Friendship (and that pretty marine lady he saw, who was later on revealed to be Captain Hina) that motivated this choice. The former example made the change by killing a fellow marine For the Evulz. Both of these characters are still antagonists to the Straw Hat Crew, no matter what side of the law they're on.
- Head Jailer Shilliew was one of the more ruthless arms of the Government, then they locked him away for his treatment of prisoners. He was then freed by and joined the Blackbeard Pirate crew.
- In Nabari no Ou, Miharu runs away from Banten and joins Kairoushuu.
- Several villains towards the later arcs of Naruto — namely Sasuke, Orochimaru and Kabuto — go through some kind of revelation and let go of their Card Carrying Villainy. Even though some of them actually go ahead and lend the good guys a hand as a result, it is still made very clear that they're only doing this because the current threat is too over-the-top even for their tastes, that they're still not 'good guys' in any capacity now, and that the answer to "well, which side are they?..." is "their own".
- Mayuri Kurotsuchi from Bleach. We meet him as an horrifying Psycho for Hire and Mad Scientist without any shred of morality. Later arcs have him still as a crazy SOB, but one that at least is pragmatic enough to not provoke the Gotei 13 higher-ups and then goes against an even crazier and more amoral mad scientist...
- Avatar: The Last Airbender The Rift: With the War over the elite Fire-nation squad, the Rough Rhinos, have become mercenaries and now guard a joint Earth Kingdom Fire Nation run factory. They're still hostile towards the main characters and by books end their employer, Loban, is revealed as corrupt. After the conclusion it's unknown what happened to them but Vachir at least was seen marching in the Spirits' Friendship Festival with the reformed Loban.
- Fables has many protagonists whose past histories range from morally ambiguous to outright villainous, and while they are the good guys now many don't express any regret for their past crimes, and have simply switched their loyalties (often out of self-interest) to their new community, which was formed more out of pragmatism and self-preservation than a desire for any sort of atonement.
- Possibly the most pronounced example of this is Bigby Wolf who has simply taken the wolfish instincts of protecting family, pack and his territory and transferred them to Fabletown rather than solely himself, and is totally unrepentant for the thousands of sentient creatures he devoured for sport in his previous life.
- Another example is Frau Totenkinder (if there's a mysterious unnamed witch in any fairy tale, it was her,) whose magic is explicitly drawn from murdering children, and undertakes Fabletown's protection with the same amorality she's always had.
- In Game Theory, Nanoha joins Precia, but both sides of the conflict are sympathetic.
- In A Gun to Love's Head L and Light don't really change that much after they've become allied with each other. They work together, they solve cases together, and sometimes they write in the notebook and kill together.
- In the film of Watchmen, Dr. Manhattan does this at the end, defecting to Ozymandias' side from Rorschach's.
- By the third Pirates of the Caribbean everybody drops all and any pretense of decency and contracts Chronic Backstabbing Disorder. In other words, they basically become pirates.
- The Legend of Frenchie King: Louise and Maria are the Villain Protagonists, and they fight each other for a ranch with oil. At the end, Maria and her brothers become part of Louise's gang because the two come to respect and befriend each other after a Cat Fight, and also because her brothers have married Louise's sisters.
- In the Warchild Series, the main character changes his allegiance three, arguably four times. And each time is subtle and we're not quite sure if he's sided with the "good guys" (if there are any) or not. He's not even sure, half the time.
- The Chathrand Voyages features a ton of this. It's set on a ship populated by a full Morality Kitchen Sink, with a mind-boggling Gambit Pileup between almost every character. This means the three main protagonists are constantly switching allegiances depending on who's the most likely to help them stop whatever evil plan is the most pressing at the moment.
- Diana Ladris, the Dark Chick in the villainous group of Gone, switches from Caine's side to Sam's side at the end of the fourth book,, but she's always been loyal, primarily, to herself, and this doesn't seem to have changed that, seeing as she only switched once she lost most of the control she had over Caine after sleeping with him. Her decision was implied to have been partly out of conscience, partly out of self interest, and partly because she's pregnant.
- Alex of A Clockwork Orange pulls a few of these, but his most notable was at the very end when, furious at the revolutionaries' manipulation of his condition (intentionally driving him to a suicide attempt, hoping to garner public fervor against the government), he accepts the help of the government that brainwashed him in the first place. Of course, this is more Evil vs. Evil than Grey and Grey Morality.
- In Harry Potter and the Deathly Hallows the Malfoys never actually become good but after getting Draco back they basically turn neutral. Draco starts his Hazy Feel Turn after he realizes he doesn't have what it takes to kill Dumbledore and Narcissa was never really that evil to start with, certainly not compared to her husband and sister.
- Archvillain: Kyle joins forces with Mike after he learns that Mike is actually a Living Weapon created by Kyle's future self. The morality of the turn is unclear, since both sides were more-or-less gray to begin with.
- Buffy the Vampire Slayer: Spike relapsing back into his blood-drinking ways, only to be outed as a Manchurian Agent.
- Angel: Wesley stealing Angel's baby, then going solo for a while.
- Several characters in Heroes, most notably Nathan, have done this at some point or another.
- Dear god, Dollhouse. Dominic's betrayal is probably the best example.
- The second season of Boardwalk Empire has the Commodore, Eli, and Jimmy conspiring against Nucky. All of these characters used to be on the same side, but Jimmy and Nucky are portrayed as sympathetic Villain Protagonists before and after the sides changed. The only hint that the conspirators are supposed to be the "bad guys" is that the Commodore and Eli have gotten much less sympathetic treatment lately.
- The X-Files:
- Assistant Director Skinner. In the early seasons you weren't sure if you could trust him or not. Later on, when private scenes with Skinner revealed him to be an unwilling patsy for bigger forces, the adversarial relationship with his agents became somewhat redundant.Doc Oho: It's very nice to have Skinner involved in a regular investigation for once rather than having the light of suspicion thrown on him in the mythology episodes. Sometimes I wonder what he gets up to when he isn't having guns pointed at him by Mulder and Scully in their annual vendetta against him.
- Alex Krycek makes even less sense. He has a terrible case of Chronic Backstabbing Disorder, but it can be hard to tell just who he's backstabbing at any given time. Starts out as The Mole, until his bosses try to blow him up, and winds up in a few Enemy Mine situations with Mulder (resulting in much Foe Yay). He'll also try to play all his enemies off one another at the same time, until it's impossible to tell if he's working for anyone but himself. This tends to lead to him being The Chew Toy whenever he gets caught.
- Assistant Director Skinner. In the early seasons you weren't sure if you could trust him or not. Later on, when private scenes with Skinner revealed him to be an unwilling patsy for bigger forces, the adversarial relationship with his agents became somewhat redundant.
- Scorpius; after seeking asylum on Moya in the fourth season he becomes much cooperative with Crichton and the rest of the cast, but still puts his pursuit of wormhole technology above all and doesn't hesitate to scheme and back-stab his way to get it.
- Crais pulled it somewhat earlier, leaving the space-fascist Peacekeepers and becoming the captain of Moya's hybrid child, the gunship Talyn, but remaining ambiguous for quite some time.
- Jack Bauer crosses the line of FaceHeel Turn sometime late in the final season of 24 when he goes on his Roaring Rampage of Revenge, but it's a little unclear whether he does it the second he initially goes rogue or originally had the more noble purposes he claimed he was carrying out and only went over it after executing Dana Walsh.
- The Vampire Diaries has Stefan in the third season. Made so much murkier because vampires can turn their conscience on and off. For much of the season, he goes off the rails and it's hard to tell what his actual motives are.
- The comic packaged with the Masters of the Universe figure Modulok tells that he formerly worked for Skeletor, but tired of him, joined Hordak to destroy his former master.
- Revolver Ocelot from Metal Gear switches sides so often in a confusing world that it's impossible to tell if he's on the right side.
- The Praetorian Morality missions in City of Heroes are like this. It basically amounts to picking which side you like more.
- One thing Deus Ex: Invisible War arguably improved is that it removed its predecessor's rigid alignment of forces that forced-allied the PC with the conditionally good Illuminati against the unconditionally evil Majestic-12. Now everybody is a different kind of asshole and the PC is free to switch allegiances like gloves.
- Fallout: New Vegas allows you to switch it up as you want, and while say the Legion is evil, they also made peace out of the chaos of Arizona. It's up to the player to make a heavy choice between the Good-but-ineffective-and-corrupt NCR, the Limited-freedom-but-still-free Dictator, or the Evil-but-keeps-shit-in-order Legion. Alternatively, you can seize power for yourself, which turns into Objectivist Anarchy.
- The Arcade Ladder endings for Liu Kang and Shang Tsung in Mortal Kombat 9: Liu Kang replaces Raiden as the Thunder God and Protector of Earthrealm, and becomes Drunk with Power. Bo'Rai Cho takes on Shang Tsung as a student and teaches him techniques that will allow him to defeat the power-mad Liu Kang.
- Ingress features the Resistance and Enlightened factions, both of which are chock full of Gray and Grey Morality and one of which the player decides on when starting the game. If the player changers their mind, they may request a faction change, but it can be done once and only once, and comes with the penalty of losing all claimed portals and resetting to Level 1.
- In Crash Bandicoot 2: Cortex Strikes Back, after Crash allies himself with Cortex to save the world, Nitrus Brio, formerly Cortex's Number Two, assigns minions old and new to stop you when the plot turns out to be a trick by Cortex to obtain the world's power crystals, Brio gladly allies with Crash to dispose of him. While Ripper Roo and the Komodo Brothers' alignment remains ambiguous throughout the series after (they attack both sides on different occasions but never officially join Crash or Cortex), N Brio and Tiny Tiger revert to bad guys, even allying with Cortex again later on. This is particularly odd for Tiny, who despite first appearing as one of Brio's cohorts, is retooled as Cortex's Undyingly Loyal creation.
- Red vs. Blue:
- Sister initially ends up on the Red Team due to screwing up her orders, then later switches to the Blue Team when the other characters figure the matter out. Considering both teams are pretty much the same as the other, and the apathetic nature of the teams' conflict by that point, it doesn't really matter all that much.
- Professional Butt-Kisser Simmons makes a similar change, and nobody but Sarge takes it seriously, and even then, Sarge is only upset because Simmons painted himself Blue.
- In 8-Bit Theater, Black Mage leaves the Light Warriors to join the Dark Warriors. Drizz'l, the leader of the Dark Warriors, is voted out with Black Mage being the new leader. Drizz'l joins the Light Warriors. Then the other group of adventurers shows up, and is confused about who they should and should not be fighting, due to Black Mage switching sides. Then they hold another election. Then things get complicated, and Black Mage starts stabbing people.
- Pretty much any time someone changes sides in Erfworld. Especially Charlie, a mercenary who's officially in the business of solving problems for clients, but has no problem letting clients get in deeper trouble so he can get paid more in the long run.
- Girl Genius has a lot of shades of gray in its characters, which can lead to a lot of this going on.
- Tarvek switching from the Storm King Conspiracy to Agatha's side and his own plan (which still ends with him as the Storm King) is a good example.
- Brother Ulm of the Corbettites seems to suddenly turn on Agatha, but he's not a bad guy, he honestly thinks (and given her family's history has every reason to think) that she is a danger to his fellow monks and will unleash some monster they have chained up. He becomes agreeable again when someone else unleashes the beast and Agatha insists on helping stopping it.
- In the Prolecto series, a few of the succubi end up undergoing this. They decide to change things, because the world sucks... but then behave with remarkable control.
- Quouse DND: Lia went from working with thugs, to working with some shady figures for 10 years, to working with the party trying to save the world, to marrying or rather, scamming, a rich noble from Quarmar before performing an apparent final Heel-Face Turn and running off with Jojo. Needless to say, nobody's quite sure whose side she's on anymore.
- Noob can have this happen due to the MMORPG in which it's set eventually having three mutually hostile factions, but all the main characters at least starting out as a member of the same one, which is the Empire. A webseries-only arc had Master Zen using his Empire avatar, but otherwise playing Knight of Cerebus to the protagonists before switching to the Order after it gets introduced in the game. The introduction of the Order also pushed Spectre, the Coalition's former top player, out of his retirement to join the new faction.
- Happens a lot to the Dai Li in Avatar: The Last Airbender and The Legend of Korra: They were loyal to Evil Chancellor Long Feng, then started serving the Fire Nation after Ba Sing Se's fall. By Korra's time, they are unquestionably loyal to the tyrannical Earth Queen.
- At the end of the second season of Gargoyles, David Xanatos lets the clan move back into their castle. He never actually repented for his misdeeds; he was just appreciative when the clan saved his son and redirected his energies away from screwing with them. Giving them the right to live in their castle didn't really require any sacrifice on his part anyways. The short-lived comic confirms that Xanatos is still plotting, he just tries to keep the Gargoyles out of it and he still has backup plans in case they interfere.
- Charmcaster at the end of both Ben 10: Ultimate Alien and Ben 10: Omniverse ends up not really being on the side of good but no longer up to anything evil either.
- Peridot from Steven Universe has absolutely no emotion regarding the Cluster experiments, nor does she have any remorse for trying to kill the protagonists... but the moment she realizes she's trapped on the soon-to-be-destroyed Earth, she immediately reverses course and starts trying to help save it, mission be damned, even reluctantly accepting help from those she was until recently trying to kill. And when she completely burns her bridges back to Homeworld, the Crystal Gems effectively become her only allies.