The Heroic Antagonist

Sometimes you have to be bad to fight bad.

The "antagonist" who has to fight the true antagonist who was formally a real protagonist to end the story happily for everyone else, which would actually end the story unhappily since the protagonist will be defeated should the Heroic Antagonist win in their fight. Are you confused yet. The reason behind the Heroic Antagonist rising up against the protagonist can be the protagonist actually was a Good Guy until they were corrupted or the protagonist was always what would traditionally be considered a Villain or Villain-like role. If the protagonist was not already friends with the Heroic Antagonist, it might be revealed that the two could potentially have been friends if things were more favorable for the real Good Guys (and the Innocents if the protagonist poses a threat to them).