A friend of mine had a project that did this in a way I thought was fantastic. The MC was collecting allies who would stand against the evil that was forming from the chaos and death that the constant warring for the past decade was forming. He went around, finding everyone who could and would help out. They all trained and looked for equipment to fight the evil. However, there was a legend going around about a lord who would take the power of evil. This legend starts to pop up as the rival party shows their faces. You finally beat the rivals, stopping them from gaining power, and fight the great evil.
Then the MC strangely jumps at the corpse, stunning the party. And as he gather energy from it, the party realizes
he is lusting after this power. He goes to explain that he wanted to get everything that could possibly slay him in one room after learning the weaknesses of the party and legendary items. And now suddenly you have to refight the final boss who is smarter and has your old MC alongside it.
What made it so brilliant was the subtle feeling that the woman who joins the party about 1/3 of the way through was far more likable and sympathetic of a character, that you'd eventually just like her more than the MC. After you beat him, she "finishes" the story.
Also, to really drive home that it's the MC, his stats are the same and he steals all the equipment he's wearing. (After I trolled the final boss a second time by removing all the MC's equipment before the first fight, my friend instead makes it so he unequips everything, then equips the legendary gear only he can wear and is required to get here with, so only his levels and skills actually can change).
Attention was payed to so that you would notice all the clues that the MC was bad your second playthrough. And in new game+, you could actually fight the MC at any time as a Superboss and change the story.
If it's not the MC, the blow is much weaker. Even if it is, there's a pretty famous example of losing the MC on the SNES;
Spoiler: Giant Plot Twist
Crono in Chrono Trigger sacrifices himself to save the party. And saving him is a sidequest.
If the story demands it, the story demands it.