The Heroic Antagonist

Sometimes you have to be bad to fight bad.

The "antagonist" who has to fight the true antagonist (who has taken the role as the 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. 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 tradionally 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).