* ''Literature/AdventureHunters'': Both Ryvas and Marcus are fully aware of the vileness of their actions but believe them to be necessary to save the kingdom.
* ''Literature/{{Animorphs}}'':
** This is a common theme in the series. The main characters (who are only 13-16, mind you) are forced to do some terrible things to prevent both humans and countless other alien species being enslaved by a PuppeteerParasite species. This includes trapping another kid in a rat's body because he turned traitor, killing sentient beings so their bodies can't be used as hosts, manipulating an ActualPacifist to go against their nature to kill...in the very last book they [[spoiler: kill tens of thousands of unprotected Yeerks]]. When they're accused of war crimes, this is their justification.
** In the prequel ''[[Recap/AnimorphsTheHorkBajirChronicles The Hork-Bajir Chronicles]]'', [[GeneralRipper Alloran]] gives the order to create a [[SyntheticPlague Quantum Virus]] to wipe out the Hork-Bajir, rather than let the Yeerks use their bodies. [[AllForNothing And then the Yeerks take over the planet anyway]]. It's debatable whether he ever truly shows remorse for his actions.
* In ''Literature/ABrothersPrice'', Cira says this a couple of times [[spoiler: while rescuing Jerin from kidnappers, some of whom she kills]]. She would, of course, normally not have exposed a delicate young man to such cruelty. In the backstory, some princesses, after seeing a play about a civil war, at the end of which ''toddlers'' were executed, reason that their ancestors did what they had to do, as any survivors would have led to a [[YouKilledMyFather You Killed My Mother]] situation. [[spoiler: That said, when faced with a similar decision at the end, they ultimately choose to TakeAThirdOption to avoid either option.]]
* In Creator/PoulAnderson's "The Burning Bridge", when a message from Earth is causing people to want to turn back, TheCaptain fakes a more imperious message to inspire them to go on -- and when he's caught, makes it appear that the crewmember had gone crazy and has them put him into deep sleep.
* In the fourth ''Literature/CodexAlera'' book, ''Captain's Fury'', the First Lord Gaius Sextus has one of these moments when [[spoiler: he deliberately triggers a volcano over the city of Kalare, wiping out everyone in the city: rebels, civilians, and slaves all alike.]] He's forced to do this because [[spoiler: High Lord Kalarus was planning to wait until hundreds of thousands of people, refugees and Legion troops from both his army and the loyalist Alerans had entered the city before triggering the volcano to kill ''everyone''. Thanks to Gaius, only the city was wiped out, instead of the region. It did destroy all of the smaller towns and steadholts in within the ring of mountains surrounding Kalus, but it was still far less than would have happened if Kalarus had had his way.]] The two Cursors who guided him there, who had no idea Gaius was planning this, refuse to accept his justifications and resign on the spot.
%%* The [[http://www.sylviaengdahl.com/trilogy.htm Children Of The Star]] trilogy by Sylvia Engdahl meditates on this concept in detail.
%%Administrivia.ZeroContextExample* Robert Wingrove's ''Literature/ChungKuo'' series
* ''Literature/DaystarAndShadow'': When Robin feels guilty for interrogating some priests, then killing them for knowing too much and [[FieryCoverup burning the church down]], Shadow reminds him that it was necessary.
* ''Literature/DiscoursesOnLivy'' talks about how necessity must sometimes trump what is good for the sake of preserving liberty.
* ''Literature/{{Discworld}}'':
** Subverted in ''Literature/NightwatchDiscworld'' when Vetinari suggests that a monument be erected to the watchmen who died in the Glorious Revolution of May 25th, engraved with the phrase "They Did the Job They Had to Do." Vimes angrily replies, "No! They did the job they didn't have to do, and they died doing it, and you can't give them anything."
** Reinforced and played fearlessly straight in ''Literature/CarpeJugulum'' where Mistress Weatherwax declares that there are no shades of moral grey, "only white that's got grubby". In her view, when a thing is right, it's right, even if it gets your hands dirty.
* ''Literature/TheDresdenFiles'':
** In ''Literature/SummerKnight'', [[spoiler:Aurora]] says that she must stop the interchange between the Summer and Winter Courts, and it's [[DirtyBusiness horrible]] but she didn't set the price.
** In ''Literature/{{Changes}}'' this is what Harry does. [[spoiler: He'll go all out to do anything for his goal to save his daughter's life, including taking the position of the Winter Knight, killing the old one in the process, getting all his friends at risk of death, even destabilizing the White Council and most of all, killing his lover to use the very dark magic his enemies sought to use on him right back at them]].
--->'''Harry:''' [[spoiler:I used the knife. I saved a child. I won a war. God forgive me.]]
* The witch Senna Wales of ''Literature/{{Everworld}}'', as mentioned above, occasionally says something to this effect to the other main characters in reference to her [[TheChessmaster schemes]], which often involve some poor sap being [[CompellingVoice bewitched]].
* In ''Literature/TheFoundationTrilogy'', one of Salvor Hardin's mottoes is "Never let your morals prevent you from acting correctly".
* Raj Whitehall's computer mentor, a WellIntentionedExtremist if ever there was one, and his wife Suzette are always telling him this one in ''Literature/TheGeneralSeries''. To Raj's credit he never quite accepts it.
* ''Literature/GoToSleepAJeffTheKillerRewrite'': Liu's final words are "W-why?" after Jeff stabs him. He says that he had to, so his family would no longer need to live in this cruel world. Of course, this reasoning is dubious since Jeff has just snapped to his insanity.
--> '''Jeff:''' I- I had to Liu. I promise you'll go to a better place now. You'll be asleep with Mommy and Daddy, and not have to live in this sick and terrible world. Please, [[TitleDrop go to sleep]].
* One of the main themes of ''Literature/GodEmperorOfDune''. Leto II has the ability to see the future to a (not entirely) unprecedented extent, and has seen that humanity, as a species, will die somewhere down the line if civilization is not altered from its present course. This leads him to turn himself into a tyrannical GodEmperor who ruthlessly and callously manipulates and uses everyone around him, and also includes limiting technology and a eugenics program. This state of affairs lasts over 3,000 years, and throughout it all Leto II is shown to hate what he's doing, wishing that things could have gone another way... but his future sight has determined that only through this despotism can he prevent the death of humanity. Eventually, his plan reaches its [[ByronicHero Byronic conclusion]]. [[spoiler:The chaotic fallout from Leto II's assassination and the end of his oppression eventually triggers the Scattering: a galaxy-scale diaspora that eventually causes the human race to diversify, which is what Leto's visions had shown to be the way to save humanity.]]
* ''Literature/TheGraceOfKings'': Kuni Garu genuinely feels terrible about attacking the rival king Mata Zyndu [[TruceTrickery right after declaring peace]], but believes that Zyndu's BloodKnight nature makes another war inevitable, so he owes it to his people to end Zyndu's reign as efficiently as possible, personal honour be damned.
* ''Franchise/{{Halo}}'':
** In ''Literature/HaloFirstStrike'', intel agent Haverson shoots a perfectly nice Engineer who had just voluntarily fixed the Chief's armor. When questioned on it, he states that he'd have rather not done it, but he couldn't risk the Engineer being captured by the Covenant and providing them with information on the armor. [[note]]In the same book, Cortana realizes Covenant slipspace drives and practices are deliberately limited, and circumvents those limits [[DangerousForbiddenTechnique to jump inside atmosphere]]. A Covvie AI leaks this info to its masters before Cortana can stop it. In Halo 2 and ODST, Regret's devastating slipspace jump over New Mombasa was [[NiceJobBreakingItHero only possible because of Cortana]].[[/note]] Later, when the ''Gettysburg-Ascendant Justice'' is forced to abandon the Eridanus Secundus rebels to the mercies of the Covenant, Chief asks Whitcomb if they did the right thing; Whitcomb replies that it probably isn't, but that they have a duty to the people of Earth, not "a pack of privateers and outlaws". That said, he still clearly regrets it and mentions that [[ImGoingToHellForThis there'll be a place in Hell for him for this]].
** In ''Literature/HaloGhostsOfOnyx'', Halsey actually invokes this; she asks Kurt why he added a bunch of illegal and dangerous modifications to the Gamma Company Spartan-[=IIIs=], with Kurt replying that he did it so that Gamma might have a chance of actually surviving their battles. Halsey then says that they're not so different, and goes on to explain why she summoned him and the other Spartans to her.
** In ''Literature/HaloShadowOfIntent'', Shipmaster Rtas 'Vadum gave the orders to quarantine and sterilize Flood-infected ''High Charity'' in order to prevent the highly-virulent parasite from spreading, despite the fact that a lot of civilians were still stuck there. Prelate Tem'Bhetek seeks revenge on him for this, as his wife was one of the victims. When the two finally have a chance to talk; Rtas reveals to Tem that he only gave the order after all his efforts to rescue ''High Charity''[='s=] remaining citizens had failed, and it's clear Rtas wishes he could have saved them all.
* This is a running theme in ''Literature/HammersSlammers'': in war, you can't keep your hands clean unless you want to lose. The Slammers are well aware of this. Some of the groups that hire them are shocked to find it out -- the hard way.
* Both Dumbledore and Snape from ''Literature/HarryPotter''. Also implied when describing [[KnightTemplar Crouch's]] decision to allow aurors to use the Unforgivable Curses during the first war with You-Know-Who. And Harry himself doesn't come away all squeaky clean in ''[[Literature/HarryPotterAndTheDeathlyHallows The Deathly Hallows]]'' either, throwing around [[MindControl Imperius-curses]] left and right, not to mention when he uses the [[AgonyBeam Cruciatus Curse]] against the death eater Amycus Carrow.
* In ''Literature/{{Hero}}'', Goran uses this exact phrase when Thom asks him how he got himself and his little brother out of their war-torn homeland. What makes it chilling is that that's all he says; we never find out what he actually did.
* ''Literature/{{Hurog}}'': In ''Dragon Bones'', this is the justification Ward gives for working together with the villain, which includes giving the villain the eponymous dragon bones. Oreg doesn't buy it. [[spoiler:They TakeAThirdOption in the end.]]
* Livia in ''Series/IClaudius'' ruthlessly manipulates and kills family members and anyone else close to them to ensure her son becomes emperor and Rome does not return to being a Republic, convinced this is the only way for the city to remain great.
* ''Literature/ImTheVillainessSoImTamingTheFinalBoss'': Keith Elgrid, Claude's servant, started illegal demon trafficking with a landlord to get permission to borrow the latter's lands for demon refugees of Claude's forest. He only did so because of the threat of eviction, and he only picked demons who consented to be smuggled.
* In the ''Literature/ImperialRadch'' series, the empire of the Radch fervently believes in the interdependent values of "Justice, Propriety, and Benefit", and Lord Anaander Mianaai claims that all of her actions, however heinous, are intended to benefit the Radch. Breq counters that when every individual Radchaai citizen knows that they could be killed on her whim, Mianaai's not doing a very good job of being Just or Proper and has a [[DespotismJustifiesTheMeans pretty self-serving]] notion of Benefit.
* ''Literature/InDeath'': Eve and Roarke have had to defend their actions more than once and they have even said this trope practically word for word to each other.
* ''Literature/IndustrialSocietyAndItsFuture'': Kaczynski only briefly mentions his bombings, saying he did them for attention so people would become aware of how industrial society oppresses humanity and must be destroyed, or else we all may turn into complete slaves of our technology. Getting the manifesto published turns out to have been entirely Kaczynski's goal with them. He claims otherwise if it was published very few would have ever read his work.
* The ''Literature/{{Lensman}}'' universe generally leaves this as an unspoken trope for the good guys, but it's out there in black and white at the end of ''Triplanetary''. The sum total of the mayhem each side has wreaked on the other is tallied up once hostilities have ceased, with those responsible on ''both'' sides declaring the trope and openly admitting they wish they could take it back.
* Zack invokes this trope quite a lot in ''Literature/TheMentalState'' in order to justify the extreme methods he uses to survive in prison and improve the quality of the prisoners' living conditions.
* Brent Weeks' ''Literature/TheNightAngelTrilogy'' is full of these, usually from Logan. When [[spoiler: newly made King]] Logan flips a table, breaks a leg off and brutally smashes in the arms and legs of [[spoiler: his best friend Kylar]], who is slowly dying a torturous death on 'the wheel'. [[SugarWiki/MomentOfAwesome He then gives an ultimatum]] to the Laeknaught,[[{{Pun}} shattering]] his "good boy" image. He also says this verbatim to [[TheAtoner Count Drake]] after he [[spoiler: bends knee in allegiance]] to [[SmugSnake Terah Graesin]].
* When George shoots [[spoiler:Lennie]] in ''Literature/OfMiceAndMen''. After [[spoiler:Lennie kills Curley's wife]], George is forced to shoot him so the other men don't. He does it in a way so [[spoiler:Lennie]] doesn't realise, which the other men would not have given the courtesy of doing.
* Mr. Sellars in ''Literature/{{Otherland}}'', the MysteriousInformant for the good guys, is very much TheChessmaster and shamelessly manipulates people in order to advance his schemes, the most disturbing of whom is an innocent six-year-old girl. In the end, his justifications ring hollow even to himself, especially once his dark secret is revealed and it turns out that his core motivation was entirely selfish.
* In the first book of ''Literature/TheQueensThief'', the Queen of Attolia is presented as a vicious tyrant who hangs disloyal barons from the walls of her palace, tortures anyone disloyal, and ruthlessly destroys her foes. The second book shows ToughLeaderFacade, revealing that she is so ruthless because anything less would lead to either a forced marriage or a civil war, in which her country would surely come under the heel of a greedy baron that would carelessly bleed it dry. By making herself untouchable and terrifying, and giving no quarter to any disloyalty, Attolia ensures that her people have a ruler who actually cares about the well-being of all their citizens, not just the rich and powerful ones.
* In ''Literature/RedHarvest'', "a man's got to do what a man's got to do" is favorite phrase of Noonan the chief of police. Ironically, he uses it any time he does something that would benefit him -- such as manipulating a witness to convince her that her husband's killer was the man he had a grudge against. Literature/TheContinentalOp repeats the phrase before searching a dead lawyer's pockets for potential blackmail materials.
* ''Literature/ASongOfIceAndFire'' has several characters who will give this reason for their actions, but none can compare to the sheer lengths that Bloodraven went to to exterminate House Blackfyre and their claim to the Targaryen throne. He broke every taboo in Westerosi society, up to and including murdering Aenys Blackfyre under a flag of truce and diplomacy, in the pursuit of his goals. The murder of Aenys was considered heinous enough that his favorite grand-nephew, King Aegon the Unlikely, the direct beneficiary of that action, exiled him to the Wall for it. But this may well be a case of Main/TheExtremistWasRight, because Aegon's reign is largely untroubled by the threat of another major uprising by the Blackfyres.
* ''Franchise/StarWars'':
** The rulers of Kegan in a book of ''Literature/JediApprentice'' made their planet into a [[StepfordSmiler Stepford-Smiling]] mess, but feel justified in not just doing it, but preserving the status quo. Oddly, they do seem to have actually made correct predictions about the rise of TheEmpire. However, even though they were correct, it wouldn't have done them any good; even isolated, there was nothing to stop the Empire from coming after them.
--->''"Everything we have done [[WellIntentionedExtremist is to protect our citizens from a fate they cannot imagine]]. Perhaps some of our measures seem harsh, but they are only for the General Good."''
** In ''Literature/BattlefrontTwilightCompany'', the Rebel Alliance infiltrates Sullust and captures a facility on a [[ClimacticVolcanoBackdrop volcanic mountaintop]]. In preparation for the Imperial counterattack, they place scouts and ambushers in spiderholes on the slopes and base of the mountain. However, when the enemy [[TheCavalry cavalry]] arrives and begins to overrun the forward lines, the Rebel commander is forced to [[spoiler: [[ShootTheDog mortar his own troops]]]].
* In ''Literature/ThisImmortal'', this is what Conrad's excuse for having founded [[LaResistance Radpol]] as Konstantin Karaghiosis and engaged in prolonged guerrilla warfare, reducing the number of uncontaminated areas on Earth even further, boils down to. When Hasan points out that none of what they did changed anything in the long run, Conrad counters that at least their actions prevented the situation from getting worse.
* ''Literature/TrappedOnDraconica'': [[spoiler: Taurok]] hates every single order [[spoiler: Gothon]] gives him over the course of the story but follows them to keep his family safe.
* Inverted in the ''Literature/VorkosiganSaga'' novel ''Barrayar'': newly-made Regent Aral Vorkosigan is faced with either upholding the rule of law or sparing the life of a boy who accidentally killed someone in a duel--a crime punishable by death. He eventually chooses the law, but [[DirtyBusiness feels miserable about it]]. Even knowing that he Did What He... you get the idea... doesn't comfort him much.
* ''Franchise/Warhammer40000ExpandedUniverse'':
** ''Literature/TheEmperorsGift'':
*** The [[spoiler:Inquisition's, and also Hyperion's,]] excuse for slaughtering the civilians and guardsmen who took part in the campaign to retake Armageddon. They argue it's better for a few thousand potentially corrupt souls to die than risk having to potentially slaughter millions of innocents in the future because they let the thousands live.
*** Inquisitor Kysnaros' view of why he is prolonging the conflict with the [[spoiler:Space Wolves]]: in his view, not bringing them to heel runs the risk of the Imperium sinking into a civil war on a par with the Horus Heresy.
*** Grand Master Joros advises Kysnaros to open fire on [[spoiler:Logan Grimnar]]'s fleet, in the hopes of either forcing [[spoiler:Grimnar]] to capitulate or taking him as a hostage to force the [[spoiler:Space Wolves]] into compliance. He even admits this when [[spoiler:Grimnar]] confronts the Inquisition forces, stating his actions were for the greater good. It results in [[spoiler:Grimnar burying a power axe in Joros' chest]] and the [[spoiler:Space Wolves]] [[TheGlovesComeOff effectively declaring war on the Inquisition]].
** ''Literature/GauntsGhosts'': Colonel-Commissar Gaunt's justification for leaving Tanith to burn at the beginning of series is that the planet could not have been saved no matter what he did. It is the act of not letting the Tanith soldiers stay behind and die for their planet that invokes this trope. He made them 'ghosts' because that is what he had to do as a loyal officer of the Imperium.
** ''Literature/SoulDrinkers'': In ''Chapter War'', the Inquisitor Thaddeus lied to get aboard a Howling Griffons' ship. When they came to a head, and they try to imprison him, he kills one to escape. He once "would have never accepted the death of a good Imperial servant as a necessary evil. But he was much wiser now."
* In ''Literature/WarriorCats'', Hollyleaf gives this as a reason for killing Ashfur in order to prevent him from spilling the secret of her and her siblings' parentage.
* ''Literature/WetDesertTrackingDownATerroristOnTheColoradoRiver'': The bomber knows that blowing up Glen Canyon Dam will result in casualties, but knows it is an unavoidable consequence of restoring the river.
* ''Literature/TheWheelOfTime'':
** This is a major theme in the series with the three male main characters forced to act progressively more brutal as their responsibility grows and the situation worsens. Includes such gems as using friends like pawns, executing friends, torture by way of dismemberment, allowing bad guys to enslave hundreds of women in order to secure a temporary military alliance, creating an army of superpowered men who will eventually go insane, and purposely destroying your own humanity in order to be up for the job of saving the world.
** Inverted in that Rand's inability to kill any woman, even when she's a villain, causes his [[spoiler:mentor to die.]]
* In the Indian novel ''Literature/TheWhiteTiger'', [[spoiler:Balram believed that the only way he could become an entrepreneur and break out of the coop was to kill Ashok. Hell, when you look at how things work, he was probably right.]].
* ''Literature/WorldWarZ'' has the ''Redeker Plan'', which is basically a strategy for using refugees as zombie bait while government forces regroup. Despite the horrific inhumanity of the plan, the world's governments get so desperate that they use it anyway... and the plan arguably saves humankind (or, at the very least, prevents said governments from collapsing and leaving the world in anarchy).
* ''Literature/{{Worm}}'':
** This is Cauldron's go-to justification for all the horrific things they've done over the years: by way of OmniscientMoralityLicense, they claim that doing anything ''else'' would have led to the extinction of humanity.
** Alexandria justifies abducting innocents from other worlds, most of whom were about to die, and then experimenting on them in order to better develop Cauldron's super serum with this.
** Later, Khepri tells Contessa that, while she would have taken other actions given the choice, she does not regret what she's done.
----