Death Note has plenty of this trope, and from many characters too - Light above all, but also much from L, and a fair bit from Near, Mello and even Light's dad - although certainly not always sincerely so.
Hughes Gouli from Overman King Gainer belief in Exodus is so much that he states that he will do anything so that they can reach Yapan. During an attack that causes people's thoughts to be broadcast he reveals to Sara that he killed Gainer's parents for being against exodus.
Neptune and Uranus from Bishoujo Senshi Sailor Moon (seasons S, Stars and the SuperS TV special) consistently fail to learn from their mistakes and are willing to sacrifice lives - both innocent civilians and their own fellow soldiers - on the basis that the end (destroying the enemy) automatically justifies the means. Given that in the realm of Sailormoon, what consistently defeats the villains is the power of unconditional love and not ruthless strategy, their failure to adjust to her strategy (which actually WORKS) marks them out for the Stupid Sacrifice category. Also, see end of SailorStars for a classic example of this trope dovetailing with Nice Job Breaking It, Hero.
Itachi Uchiha from Naruto practically embodies this trope, though it's a long time before this is revealed. He killed his entire clan, save Sasuke, to prevent a civil war that presumably would have resulted in even more death.
Then there is the guy who ordered him to do it, Danzo. Who turns out to actually be a badass in his own right, though he is on the "extremist" side of Well-Intentioned Extremist. He does get to lecture Sasuke on betraying Itachi's will.
Also Tobirama Senju, the second Hokage, who feels no guilt regarding how he treated the Uchiha clan. Which, to elaborate, was giving them a position of control in the Leaf's police force. Some time later, his suspicions turn out not to have been completely unwarranted.
Lelouch from Code Geass when he loses control of his Geass, and makes Euphemia kill the Japanese. He then proceeds to do what he has to do—and says as much—and kills Euphemia. Then later on he pretty much tells Suzaku that as well.
There's also Lelouch and Cornelia in the Geass Directorate. You don't take chances with those people. Even though what Lelouch and Cornelia do is considered by most, if not all, of the people who have half an idea on what happened as disgusting, you simply don't want to risk that. Cornelia gets away with it, though - Lelouch pays for it.
Though, rather ironically, none of those people who think that it was disgusting realixe that it was a hive of Geass Users, who are Britannian assassins, who have done terrible things, murdering Shirley and a crucial role stopping the Black Rebellion amongst them. (Though that was entirely Rolo and V.V., the only ones with names.) They then attempt to kill Lelouch using the same reasoning.
More or less King's justification for having turned Demon Card into a criminal organization in Rave Master
There is a lot of this from the villains in Tengen Toppa Gurren Lagann. Generally, it turns out that they didn't, although since the Distant Finale stops somewhat before the destruction of the universe, we're not quite sure about the last set.
Windaria Alan's justification for Flooding Lunaria to stop the war and save The Valley from being a warzone
In Saint Beast, Zeus considers killing the old gods as regrettable but necessary action.
When Ichigo tries to confront Ukitake and Byakuya at Rukia's prison, Yoruichi intervenes and stabs her hand into Ichigo's wounds to insert a tranquilliser into his body so she can carry him away from the location as quickly as possible. When Ichigo comes round and demands to know why she did that and why she didn't try to save Rukia, Ganju or Hanatarou, she explains that she had to do it this way because Byakuya was too strong for Ichigo to fight and too fast for Yoruichi to be able to escape if carrying more than one person. She also knew Ukitake would protect the others from any consequences of being associated with Ichigo.
Mayuri has a confrontation with Yamamoto over taking a very important decision without first consulting Yamamoto and his response is that he had to do what was necessary because the problem required an immediate response and couldn't afford to be tied up by Celestial Bureaucracy. The decision concerned was to kill twenty-eight thousand residents of Soul Society to stabilize the cosmic balance of souls that exist to prevent the universe from breaking.
Katagiri was asked to keep a secret but felt forced to reveal it because she believed the secret would threaten the Ishida family's future. The secret was that Masaki had saved a Shinigami but Katagiri noticed Masaki received a Hollow-tainted wound. She acted based on Ryuuken's earlier statement to her that the future of the family depended on their bloodline remaining untainted. Katagiri's decision was the correct one as Masaki's tainted wound would have destroyed her had she not received treatment in time.
Ryo Narushima of Shamo uses this to justify killing his own parents (of all things!) in the first chapter of the manga. After that... well, let's just say he gets a little too used to this trope.
In Girls und Panzer, when Miho asks Maho about shooting the German flag tank when it went to rescue one of Maho's teammates, she coldly says "...Miho. What I did was Nishizumi-style Panzerkraft. I gave the order to shoot." However, when she first hears about what she did, she seems shocked and almost hurt, and when her mother tells her it was a good decision, she looks displeased.
"Get rid of the body! Even a supreme commander can't get away with the assassination of his own father. If any of you disagree, then file charges against me after the battle's over!"
Erwin Smith is a primary example of how successful commanders think in Attack on Titan, with all the unpleasantimplications that come with it. Though he cares about his men, he is perfectly willing to sacrifice them (or himself) if doing so provides a possible victory. He uses this to justify allowing a battle between two Titan Shifters within a major city, causing considerable destruction and loss of life in the process.
Buffy the Vampire Slayer Buffy the Vampire Slayer Season Nine: Buffy repeatedly justifies her destroying the source of Earth's magic to stop Twilight the previous season this way, and to be fair, there really was no other way. However, Willow insists that she will eventually have to deal with the consequences, but Buffy dismisses it; naturally, Willow turns out to be right when Dawn falls ill and starts to die without magic.
In The DCU, this is Amanda Waller's raison d'ętre.
Waller is odd in that she has a tendency to surround herself with idealists in an attempt to curb her pragmatic tendencies. When she (invariably) alienates these people, she REALLY starts to fall into this trope.
In the Elseworlds story Kingdom Come, the U.N. Director invokes this trope when he gives the order to drop nukes on the big superhero brawl. "The only way to make certain future generations will know this was our only hope... is to ensure there will BE future generations." He is later shown in his office, looking rather regretful.
Marvel Comics's Cable might as well have this monogrammed on his towels as as often as he says it in his early appearances.
Magog from Kingdom Come uses this one too, which isn't surprising as he was inspired by Cable.
Wonder Woman ends up having to say this a lot after killing Maxwell Lord (with the whole thing recorded and broadcast to boot), who was controlling Superman (and who could've killed everyone present in the time it took to come up with a better plan). The whole thing sets off the Crisis Crossover, Infinite Crisis.
This is Batman's tacit justification for every time the Justice League finds out his plans to take them down should it be needed. Interesting because Batman helps undoing them anyway. He also encourages this state of mind in his protégés, especially Tim (among others, in the form of a Dangerous Sixteenth Birthday worthy of the greatest Manipulative Bastards).
In The Long Halloween, Harvey Dent says that he did what needed to be done when he kills Falcone.
Ozymandias from Watchmen killed millions to save billions. Possibly. The ending deliberately leaves it ambiguous as to whether his gambit ultimately succeeds. Regardless, he certainly believes his actions will save billions, at least until Dr. Manhattan leaves him with the words "Nothing ever ends, Adrian".
Cyclops has spent the last decade giving up everything he believed in, from his own moral code to his own happiness and the relationship between himself and his friends, resulting in many supervillains and psychopaths being put down, causing him to be compared to Magneto, but all so he could keep the last of his kind from extinction.
He kinda succeeds after the events in Phoenix Five. Kinda.
Dungeon Keeper Ami features this a few times, when Ami has to make hard moral calls, usualy involveing a cost/benefit tradeoff of some kind. She is (technically) a designated villain, after all. Some of her minions are more willing to take the risk on her behalf, instead.
More recently, Morrigan's cheif warlock, Monteraine, defected to Ami's forces upon capture. This enrages Eline and Venna, who reveal that she was the one who implemented Venna's conditioningforMorrigan. Monteraine immeadiately offers to do the same again for Ami's minions, and it is only when it is clear that Ami is seriously considering not hiring her that Monteraine admits she had little choice in the matter.
The North Korean Digidestined in most Digimon fanfics end up in situations like these, as do China's Digidestined. Their governments force them into doing various horrifying things and the kids rationalize it with 'I did what I had to do, because otherwise they'd kill my family'. Since they're kids, this comes across as more desperate and terrified than villainous. Fandom's is fairly good about not making them evil because their countries are - at least, fandom's good about that now. There's some Dead Fic from five or more years ago where they're straight up For the Evulz lunatics.
This quote from the Villain Protagonist of the Mass Effect fanfic The Council Era says all that is needed to be said. "I will pay for taking the low ground after I die, but there always has to be someone who is willing to make such a sacrifice, for the sake of something far greater than themselves. It's part of the order of things." Keep in mind that his "taking the low ground" was committing genocide. It is likely that in the second part of the storyline, when he's expected to decline further into Chaotic Evil, that he'll still try to use the "I Did What I Had To Do" card, even if his motivation becomes Despotism Justifies the Means.
This the reasoning of the Big Bad in The Man With No Name, as well as Zeke, the leader of a town plagued by Reavers when he blackmails the heroes into helping him.
Of all people, HelenBelden in Trixie Belden fanfic Ambiguous. She's not sure of the relationship between her son Mart and his friend Dan, both teenagers, but she recognizes that Mart has romantic feelings for him. Unwilling to suffer the repercussions of losing her family's good reputation by having a bisexual son, she deliberately drives Dan away, which might have lead to him allowing himself to be captured by criminals.
Ace Combat The Equestrian War has Black Star who, as told by Firefly via Flash Back, was ordered to prevent a possibly mutiny against the Griffin Kingdom. Believing that Firefly's parents would be behind it, he killed them. When the young filly asked him why he did, this is his reason.
The kicker? The rumor of their involvement and the whole mutiny thing were false.
In Poke Wars: The Subsistence Ash has Pikachu use Thunder on a sinking ferry overrun by Sharpedo and Tentecruel. He regrets that he had to kill everyone on the ship but the Pokémon swarming the ship were too dangerous to leave alive.
Hiiro in Fool's Paradise has his Ampharos unleash Thunder in a harbor filled with Tentacruel and their victims, killing everyone in the water so the boats in Olivine City can head out to sea. He calls his plan "a horrible, despicable, but ultimately necessary idea" and he explicitly states "You won't like it" to an Officer Jenny who asks him for a plan.
Alex says this word for word to Katrina back on the caravan's encampment after rescuing her from a Hostage Situation.
The Powers Of Harmony: This is the justification used by Libra and his Echo Blair for breaking the taboo on the use of Lifeforce magic. It was the only way to stop Nightmare Moon's undying army in the War of the Sun and Moon.
A Mighty Demon Slayer Grooms Some Ponies: Megan resents a lot of the things she had to do as the protector and more-or-less-leader of Ponyland, including killing a whole lot of villains, as well as having to e.g. crush Heart Throb's dreams of having a monogamous romance straight out of a fairy tale. She had no choice, though.
In The Conversion Bureau: The Other Side of the Spectrum, the king of the dragons, Spykoran, in an effort to keep the Bag of Tirek from corrupting and controlling anyone else again, destroyed all of Dream Valley, killing any ponies that remained there along with the Six Princesses (as they'd all been corrupted), and buried it all under ash and lava. When the bag was found by an Equestrian archaeologist, he destroyed the ship as it was returning to Equestria. He does have massiveguilt and regret for killing several people, but maintains he did what had to be done.
This is Felicity Shagwell's excuse for sleeping with Fat Bastard in the second Austin Powers movie.
Which turns Austin into a huge hypocrite, since he did the exact same thing with Alotta Fagina in the first movie, to Vanessa's dismay.
With Felicity, Austin's not so much bothered about the ethics as the physics.
Any Scifi horror movie where people who are infected by The Virus have to be killed or risk having them turn on the uninfected cast. Closely related to most zombie and werewolf movies. Contrast What Happened To Mommy.
Inverted in the first Resident Evil movie. The infectee even receives the cure... and still turns into a zombie at THE WORST POSSIBLE MOMENT.
Reversed in Star Trek III: watching the Enterprise explode, Kirk asks, "What have I done?" to be told by McCoy: "What you had to do; what you always do: turn death into a fighting chance to live."
When Sarek thanks him at the end, Kirk plays it straight: "What I did, I had to do."
A light-hearted version in Running Scared (1986). The two cop heroes are in a hostage situation with a gunman who doesn't have any pants (long story). He orders them to take off their pants and give them to him so (a) he'll have a pair and (b) it will be harder for them to follow him. They do so. Later in the station house they're asked how they could give up their pants, and one of them says "We did what we had to do."
Professor Xavier, in almost all mediums he's appeared in now, frequently uses this trope to justify some of his more morally questionable actions. Specifically, in X-Men 3: The Last Stand he tells Wolverine he did what he had to do in suppressing Jean's powers and her violent Phoenix personality.
Stella: What did you do to yourself? Eben: What I had to do.
Played straight to the letter by Ozymandias of Watchmen who not only goes to ridiculous lengths to dupe the world into think they're under attack (and killing millions in the process), he also kills his beloved Bubastis in a vain attempt to kill Dr. Manhattan.
"A world at peace. There had to be sacrifice."
Featured prominently in the second of many speeches in V for Vendetta.
Lewis Protero: We did what we had to do. Islington. Enfield. I was there, I saw it all. Immigrants, Muslims, homosexuals, terrorists. Disease-ridden degenerates. They had to go.
In a more comical direction, the entire premise of John Waters' Serial Mom is a suburban woman who feels morally justified in offing people for bad manners, not recycling and fashion faux pas, like Patricia Hearst's white shoes after Labor Day. Though funny, John Waters has stated that he feels very strongly about all these grievances (especially the last).
Carriers. In a world where there's an infectious virus that kills people, pretty much everyone is forced to kill people who are infected but not yet dead. On some occasions our 'heroes' kill some non-infected people when they refused to give up gas in their car. They needed this gas to survive.
In the The Dark Knight Rises, this is done by Jim Gordon when he is called out by John Blake over hiding the Two-Face murders by blaming it on Batman. An interesting take, however, as this is suggested by Batman himself, he is never seen as a villain or a Knight Templar, and since the audience has seen the exact decision process behind it, is does seem like the best idea at that point in time.
In Dangerous Beauty, this is Veronica Franco's justification for why she became a courtesan: "I repent there was no other way open to me. I do not repent my life."
In Zombi 3 D when Dr. Holder and his assistant, Norma, confront General Morton as the infector's body is burned, Morton uses this as an excuse.
Dr. Holder: Who told you to burn the body of the man infected with Death One? General Morton: ...I had to close an episode.
''Aladdin: Aladdin justified his stealing by only taking what he needed to survive and nothing more. On the one occasion where he did take more than he needed, he was devastated to see how much he hurt someone and returned the money.
Red vs. Blue: The excuse of the Director of Project Freelancer for performing his morally ambiguous experiments.
"its a good day to do what has to be done by me and help my brother to defeat the enemys!"
The sequel is even subtitled "What Has Tobe Done."
A few lyrics to "My Way" go as thus:
I did what I had to do
And saw it through without exemption...
Warhammer 40,000. All of it... at least the "good guys". The bad guys just enjoy their work. The kicker? For the sake of surviving, they really DO have to do it.
Well, they don't HAVE to, and the brutality of their methods backfires as often as it helps. Other races, notably the Tau and the human splinters Horus dealt with before his corruption, have much greater success fighting chaos with more surgical (or at least less exterminatus- and mass brainwashing-based) methods, they just haven't caught on in the Empire because the climate of fear and absolutism is also necessary to keep the imperium in power.
Warhammer too. Burn down an entire village because of possible chaos taint? Had to be done. Burn the Witch! definitely had to be done. And this is just the humans, the other 'good guy' races are just as bad.
This is especially true for Chejop Kejak. While he maintains he did the right thing, the memories of the Usurpation still haunt the old Seer thousands of years later. It is to the point that according to his character sheet in the Sidereal Exalted manual, his Motivation (which means his main objective in life) is "Justify the sacrifices of the past", and his defining quote is: "It was necessary."
More generally, this kind of situation is what the Conviction virtue is for. According to the first edition rulebook, someone with a legendary convition (level 5) has whatit takes to put a whole nation to the sword, if it is really necessary.
Dungeons & Dragons had a version of this for PALADINS in the "Complete Scoundrel" 3.5e sourcebook: the Gray GuardPrestige Class, which basically allows the paladin to violate the code of conduct for the class with a minimal penalty if he does so in pursuit of a greater good.
There's a reason the Forsaken are called such — because they killed their father deity when they saw that he was getting weak and was unable to hunt down the spirit entities that threatened primordial Earth. As a result, they pretty much dashed Paradise to pieces, alienated their mother deity for millennia, and earned the undying enmity of their cousins, the Pure.
The Hunters say this a lot, too. Living in the World of Darkness and fighting the eponymous darkness not only requires cast-iron balls, but all too often demands a willingness to accept innocent casualties as inevitable in the name of fighting a greater evil.
Urza in Magic: The Gathering practically had this printed on a shirt. Let's put it this way: his plan to wreck the biomechanical hell of Phyrexia involved recruiting eight planeswalkers. One of said planeswalkers was a sociopathic murderer who Urza knew all along would try and kill the other planeswalkers; he let said murderer kill two, then hit the kill command for that murderer's powersuit and used his life energy to prime the bombs. While ranting about how everyone kept underestimating him, no less.
He did a lot more than that. Let's begin with the earlier years of his four thousand year life. He rose to power as a talented Artificer in Yotia. Soon he came into conflict with a neighboring desert nation led by his brother. The following war saw entire forests cut down for wood, seas poisoned, deserts burned to glass and the earth blackened. The Brothers' War devastated Terisaire and killed most of the continent's population, all to save those that did survive from his brother, who was even worse. In order to win his war, Urza used the sylex at Argoth, which was pretty much a magic nuke that changed the shape of Dominaria forever. After that the list gets even longer. He unintentionally lead the Phyrexians to Serra's realm, which was destroyed. He sacrificed friends as if they grew on trees, all in the name of revenge. In order to combat Phyrexia, Urza began a century long eugenics project to breed a savior that can defeat them. He built a school for mages only to abandon its students when the academy was trapped in time dilation. Here is a man who sacrifices friends and nations, a man to whom no price is too high to defeat Phyrexia and Yawgmoth. In the end, he even sacrificed himself to that end. All of this made his betrayal of his own cause that much worse. After all of the terrible things he did to fight Phyrexia he was seduced by its power and majesty and pledged himself to Yawgmoth at the moment of truth. He only got back on track after Gerrard chopped his head off.
While the most poignant example in the comic, not the first. Played seriously and then for laughs on this page.
Later Pella uses it after she kills innocent gnomes to force the rest to evacuate from their fortress. This makes Cale unhappy because at that point she was the only member of his party he was sure would not use that excuse.
In Harkovast, Shogun views killing wounded, surrendering opponents as perfectly reasonable, and angrily defends this concept when questioned by the other characters.
Maxim 20 from Schlock Mercenary: If you're not willing to shell your own position, you're not willing to win.
In Homestuck, Vriska Serket justifies mind-controlling an army of ghosts and sending them all to the post-death slaughter because the threat of Lord English is far bigger in the grand scheme of things than her actions. Of course, her own ego might also be a factor in this. Recently, Aranea Serket decides to steal John's ring and come back to life in order to stop English before he could ever become a threat in the first place, which involves her lying, stealing and potentially dooming the timeline and herself if her plan doesn't work; all of which she justifies this way as well.
Survival of the Fittest villain Bobby Jacks' entire justification for 'playing the game'. (The full statement being: 'I did what I had to do to survive')
An extreme example: The SCP Foundation's SCP-231 project. Pregnant girl of undetermined age carrying what appears to be some monster that, if birthed, will be The End of the World as We Know It. The only way to prevent the birth? Procedure 110-Montauk, which (while never actually described what it entails), must be carried out once every 24 hours by 6 Class D Personnel who are also convicted sex offenders. Yes, it is as bad as you think. No, the girl cannot be put out of her misery. No, the girl cannot be drugged into amnesia or unconsciousness. She has to be fully awake for the procedure to work. Yes, it is just as horrifying a prospect as you could imagine. A hidden message on the page claims the Foundation has no intention of trying to save the girl and want whatever is inside her right where it is.
Number 1: You do what you have to, and I'll do what I have to.
In Avatar The Last Airbender, this is used by Zuko twice; once in his second fight against Zhao to justify becoming the Blue Spirit and springing the Avatar, thus rendering himself a traitor to his own nation, and then again in season 3 to Iroh as his excuse for his actions during the season 2 finale. It's pretty notable that while the first is said with utter conviction, the second time it's used it more or less fails to even convince Zuko himself.
Ironically, Ratchet says the exact same thing later when Omega questions the point of war. Then again, Omega was on the verge of dying, and Ratchet probably wanted o make him feel good in what could have been his last moments.
In the finale of Beast Machines Optimus, Rattrap, Cheetor and Botanica were barricaded inside Megatron's fortress while Megatron and his Vehicons were trying to get in, but were unable to as long as the shields were up. Stalemate. However, being separated from the soil meant Botanica (Rattrap's love interest) was losing her life energy. Rattrap opened a small hole in the shields in order to get Botanica out and back to the ground - which worked, but which Megatron immediately picked up on and used to destroy the base. Optimus and Cheetor flipped out at Rattrap, who used this as his justification.
Optimus ended up dropping the issue while noting that the shields would have failed sooner or later after the initial flip out.
Again, in Transformers Prime, Optimus says this when he finally realizes that the war will never end until he kills Megatron. Since it's Optimus, he obviously doesn't go through with it. He get's interrupted when the literal Transformer Devil wakes up
Also in "Darkest Hour", when Optimus had to destroy the Omega Keys which would have revived Cybertron to save Jack, Miko and Raf.
Ratchet: All of our struggles and energon spilled and countless sacrifices, for NOTHING!? Arcee: Right decision or wrong, what's done is done...
In one episode of Futurama, a character says this to Fry after removing Bender's brain.
Ronald Reagan said, on the bombing of Libya in 1986, "Colonel Qadhafi is not only an enemy of the United States. His record of subversion and aggression against the neighboring States in Africa is well documented and well known. He has ordered the murder of fellow Libyans in countless countries. He has sanctioned acts of terror in Africa, Europe, and the Middle East, as well as the Western Hemisphere. Today we have done what we had to do. If necessary, we shall do it again."
And in 2011, we made true on his promise.
Or, at least, helped.
Harry Truman stood by his decision to use atomic bombs against Japan, saying "I knew what I was doing when I stopped the war... I have no regrets and, under the same circumstances, I would do it again." In private diaries, however, he expressed some regrets and uncertainty.
Paul Tibbets, the pilot of Enola Gay that dropped the bomb on Hiroshima said in 2005 that "If you give me the same circumstances, I'd do it again". Crew members of Enola Gay and Bockscar (the plane that dropped the bomb on Nagasaki) said similar things, except Robert Lewis, co-pilot of the Enola Gay, who had a My God, What Have I Done? moment.
This is actually the law whenever an aircraft of any stripe has an emergency. The commander of the craft is authorized to do what he has to do to minimize the harm and prevent catastrophe, and any property damage or deaths that happen as a result of this are legally just collateral damage.
Machiavelli wrote in The Prince that a Prince should not let his morals impede the running of a state. (In most academic circles The Prince is regarded as a satire. He also wrote about how a Republic and its citizens would be called upon to do what was necessary for the good of the Republic in Discourse On Livy.)
As with pilots, firefighters will try to minimize damage but if they have to break things in order to do the greater good, they can and will without hesitation. Someone parked in front of a fire hydrant? You'll see a hose running through the busted-out windows. Can't get close enough to the side of a burning building because there's a car dealership lot with a row of brand new cars in the way? Get a nearby bulldozer to plow a path through the cars.
There are morality tests that function on the standards of action vs inaction. The first situation proposed is that there is a plane with 100 passengers on that is going to crash, but the test-taker can prevent it by pushing a button. The button will kill 10 people instead. Those who opt to push the button would fall under this trope. The second situation is similar, but now there is also a lever. The lever will also prevent the plane from crashing, and it will only kill one person: the test-taker. The answers are interesting, especially to the test-taker.