This trope is pretty much the point of a lot of Greek tragedies, making this trope Older Than Dirt. A good example is Sophocles' Antigone: shall she bury the body of his brother, as divine laws prescribe, or leave him unburied (and as such cursed to a miserable afterlife) as King Creon ordered? She does what she feels is right. Tragedy ensues.
Harry gives a whole speech to this effect prior to the climax of the first book.
"If Snape gets hold of the Stone, Voldemort's coming back! Haven't you heard what it was like when he was trying to take over? There won't be any Hogwarts to get expelled from! He'll flatten it, or turn it into a school for the Dark Arts! Losing points doesn't matter anymore, can't you see? D'you think he'll leave you and your families alone if Gryffindor wins the House Cup?"
During the whole saga, Harry often breaks the rules to do what's right, to the extreme of robbing a bank, as well as using Unforgiveable Curses, in Deathly Hallows.
Sometimes, Hermione (who is always a stickler for the rules) realizes that breaking the rules is the best thing they can do.
One of Minerva McGonagall's best moments: during Umbridge's rule as Headmistress, she condones what amounts to almost anarchy at the school from both the students and Peeves the Poltergeist in order to drive Umbridge out of Hogwarts. "It unscrews the other way" will always be one of the best lines EVER in Harry Potter's books. And, in a more serious example, her use of the Imperius Curse on the Death Eaters that had become teachers at the school after Harry infiltrates it. However as with Harry's example above it's implied though that the unforgivable curses are legal under Voldemort's regime.
Most of the other teachers as well, including Snape.
Adventures of Huckleberry Finn: Huck's comrade throughout the book, fugitive slave Jim, has been captured and is to be returned whence he fled. Huck elects to break him out. This instance is a special case within the trope, because Huck in fact believes himself to be choosing wrong, and wickedness, because all the moral teaching he has ever been given has been geared to following rules, and disobedience is equated with evil. His innate moral sense triumphs anyway.
Huckleberry Finn: It was a close place. I took [the letter giving Jim away] up, and held it in my hand. I was a trembling, because I'd got to decide, forever, betwixt two things, and I knowed it. I studied a minute, sort of holding my breath, and then says to myself: "All right, then, I'll go to hell!"—and tore it up.
In The Dresden Files, this trope is one of Harry Dresden's key character traits — the man started a war over it, in fact.
Sherlock Holmes loves this trope. He even keeps a set of tools to break into people's houses and never hesitates in using them, willingly became an accessory after the fact to the murder of a particularly nasty villain, perhaps knowingly became indirectly responsible for the death of a murderer (expressing no remorse whatsoever afterwards), etc. Most impressive is that he seems to not think that the extremes he sometimes goes to solve cases is going too far, shrugging or even smiling with amusement when called out on it. This is at least partly because for Sherlock Holmes, it's more about the thrill of solving a complex mystery than serving the cause of justice; he's more interested in the mystery than the result. And, as he once lampshaded when letting a perpetrator go because he was convinced the perp was not beyond redemption, it's not his job to compensate for the deficiencies of the police.
Similarly, his contemporary Arsène Lupin. When he is not lying, cheating, and stealing to get what he wants, he is lying, cheating, and stealing to right a wrong or save someone from an unfortunate fate, even when there are multiple, more ethical, ways to do so.
During the X-Wing Series, Rogue Squadron is betrayed by one of their own, who then joins the Imperials in taking over a strategically important planet. The New Republic wants to ignore that planet for now, since attacking would be diplomatically unsound. So Commander Antilles resigns his commission and quits the New Republic, rapidly followed by the rest of Rogue Squadron. They form an independent force devoted to destroying the bacta cartel. Much later, since things turned out well, the entire squadron is welcomed back, reinstated, and told that they had the tacit support of the New Republic — the history texts would mark the operation as legitimate. (There were very strong hints of this during the story; for example, they managed to purchase their old starfighters on the cheap because someonenote It's never specified who, but likely General Cracken and/or Admiral Ackbar were responsible. in the New Republic had designated them as "broken surplus", as they were missing the parts designated "PL-1"s — the designation for "pilot". Wedge even hangs a lampshade after this particular windfall.)
Starfighters of Adumar has a similar but vastly more personal version. Wedge and his pilots have been sent on a diplomatic mission to Adumar, whose hat is pilot-worship and Blood Sport, in order to get them to join the New Republic. The Imperials have also sent some pilots. Both groups fly against native Adumari pilots and win handily, since as Proud Warrior Race Guys the Adumari never get very skilled. The Imperial pilots fly with full-strength lasers and shoot to kill; the New Republic ones do not, and Wedge's diplomatic liaison says that in not following standard native practice they are disrespecting their traditions, which means that the Imperial pilots look better. Wedge tells himself that if it was a matter of flying against some champion, some enemy, he'd do it without a qualm, but the Adumari aren't his enemies. He stalls by telling the liaison that he's waiting for his immediate superior to order him to fly lethally. But he knows that if ordered, he will refuse and end up getting kicked out at the least - which is a big deal for him, since Wedge has been part of the New Republic since he was in his teens, and literally all of his friends are involved in the military.
There's also Thrawn in Outbound Flight, who really wants to protect the Chiss, but often clashes with his culture's views on preemptive attacks, which is what eventually leads to his exile. It's morally ambiguous, and Thrawn does become a full-fledged villain later on, but it's hard to argue that the Vagaari didn't deserve everything they got.
Death knew that to tinker with the fate of one individual could destroy the whole world. He knew this. The knowledge was built into him. To Bill Door, he realized, it was so much horse elbows.
Oh, damn, he said. And walked into the fire.
This is not the first or last time Death has done this. See also Ysabell in Mort and the Little Match Girl in Hogfather. Furthermore, he was technically sacked when he saved the girl from a burning building, so there wasn't anything expressly forbidding him from rescuing her.
There was a loophole for the match girl; he was acting as the Hogfather, who's allowed to do things like that.
Sir Samuel Vimes is pretty much this 90% of the time.
Hell, even when he's in power himself, he's still breaking the rules. Summed up perfectly by Vetinari
Vetinari: That's practically zen.
Salvor Hardin in Foundation has it down to a philosophy of life, expressed in one of the epigrams atributed to him which will be later adopted by the merchants:
- "Never let your sense of morals prevent you from doing what is right."
At least Once an Episode in Dale Brown's books, Brad Elliott, Patrick McLanahan, and the Dreamland old-timers will ignore or resist the commands of higher authority in order to save the world, even if most of them wish they could work together with the conventional military rather than fight.
This is a major part of Joey Bettany's character in the early Chalet School books. She's more than happy to break rules in order to save people (or dogs, in Jo of the Chalet School).
Animorphs': Ellimist can't really "break" his rules without causing a massive, universe-destroying war with the Eldritch AbominationGod of Evil known as Crayak, but he's been shown to twist or bend them in the good guys' favor whenever possible.
At the end of the fourth Temeraire book, Laurence commits treason by stealing the cure for the dragons' illness and taking it to France, because the alternative is to let the illness spread across the world killing dragons who aren't even involved in the war. Then he goes back to England and turns himself in, fully expecting to be hanged.
In an odd villainous example, Saint Dane of The Pendragon Adventurestarted out as a good guy, who lived as a spirit in Solara and after a while couldn't stand seeing people make bad decisions over and over. His job was to just show every aspect of a situation, but instead he began to point people in a specific direction, which was technically breaking the rules. (Compare with the story of Lucifer in The Bible to get a better understanding.) Then he went mad with power and decided to become a god who controlled everything and everyone. Even though the original intent fit this trope (that of pointing man in a positive direction with his hand), at the end of the series he's just gotten plain selfish.
A very controversial example from A Song of Ice and Fire: Jaime Lannister, one of the King's bodyguards, learns that the King is planning to burn down his own capital in order to spite his enemies, thereby killing hundreds of thousands of people, including the King's own grandchildren. Jaime decides to violate his oath to protect the King and kills him as soon as he gives the order. (As well as anyone around who might either know about the order or actually carry it out.) In this case, the character in question clearly believes he's invoking this trope, but the other characters (and the readers) are far more divided. In-Universe, opinions generally range from considering it a case of Bad Guys Do the Dirty Work at best, to, (more likely) a case of Chronic Backstabbing Disorder at work.
In the Honor HarringtonExpanded Universe short story "A Ship Named Francis", after the captain managed to put himself into a coma by colliding with a bulkhead headfirst during a potato sack toboggan race, leaving the borderline psychotic first officer in charge, and decides to arrest 20% of the crew on capital charges on the first day of assuming command. Since the ship was 5 days from their home port, statistics implied that the acting captain would have executed the entire crew before they made it back. In order to prevent a mutiny and/or mass murder, the medics and bosun decide to switch the lethal injections with tranquilizers and then store the sedated bodies until they could be revived later, ostensibly to return the bodies to their families. When the bosun points out that by deliberately seeking to subvert their captain's actions, they were committing a court martial offense, one of the medics replied that he'd take his chances with a court-martial on Grayson (with a presumably sane judge presiding).
Honor Among Enemies features the crew of a Havenite warship sent to commerce raid Manticoran ships in the Silesian Confederacy who discover the remains of a Manticoran ship captured, and crew horrifically abused and killed, by local pirates. Even though the activities of pirates attacking Manitcoran ships actually aids the mission they are on, and their job certainly isn't to save Manticoran ships, the crew put their mission on hold and go after the pirates, horrified by the atrocity.
In Firebird (Tyers), Field General Brennen Caldwell discovers that a small group of rebels are almost certainly holed up in a hitherto unknown fortress creating a Weapon of Mass Destruction capable of rendering an entire planet uninhabitable — and the weapon might very well be almost finished. He reports it to a Council member (the highest power both politically and militarily), offering to investigate himself and stressing that time is of the essence, and is ordered to stay put and told that "they will look into," which translates to "we'll talk to them a lot and wade through a bunch of red tape and then maybe eventually actually send people there." So he has to decide: does he obey orders, risk the deployment of a devastating weapon, and keep his career safe, or does he break explicit orders, potentially save millions of lives, and face possible court martial? He chooses to go — a choice that is justified when he discovers a lab containing a nearly completed warhead within the fortress. The personal consequences? Aside from nearly being killed quite painfully by the rebels, he is forced to resign.
In Anne McCaffrey and Margaret Ball's Partnership, a character is running a mine with a labour force of native animals. It turns out that they are intelligent, but getting them registered as such is some kind of Catch 22 situation. He therefore breaks the rules in order to get them registered. His punishment is community work with another native species who might turn out to be sapient.
This is Firestar's way around the warrior code in Warrior Cats. As Sandstorm says, he does follow the warrior code, thinking over how it's supposed to work. And when it doesn't, he challenges it and does something different. Like when he was supposed to obey Bluestar's demands to attack WindClan, he instead arranges for a peaceful conversation without blood.
In the last book of Protector of the Small, Keladry of Mindelan, a woman who is normally entirely willing to follow the rules even when they are massively unfair, is given charge of a refugee camp in Lady Knight. When the refugees are attacked and many abducted while she's out, her superiors refuse to look for them. She disobeys orders and goes AWOL — which is treason — to follow. Later, she turns herself in, fully expecting to be tried and executed. She's not, and neither are her friends who also broke the rules to go with her so she wouldn't be immediately killed in the rescue attempt. Her superiors realized after she went that of course she would do that, and the lord who gave her the order to leave the refugees actually is furious with himself for doing it. They also realize that the enemy could have made two hundred Nigh Invulnerable killing devices if someone hadn't rescued the refugees.
In Mastiff Pounce heals Achoo when she's wounded, despite knowing that the gods will be very angry at him for using his powers in mortal affairs. They bind him to his stars for a century afterwards, which all things considered is a rather light punishment.
In Twilight, Carlise Cullen is the leader of a group of vampires in the middle of a centuries-long feud with a group of werewolves living in the same area. The only thing keeping the peace between the two is a treaty, part of which stipulates that the two sides stay off each other's land and have little, if anything, to do with each other. However, when one of the werewolves is wounded, Carlise immediately offers his medical services and helps treat the young man. This helps to begin bridging the gap between the two groups.
In Artemis Fowl, Captain Holly Short does this all the time. She directly disobeys orders from superior officers to do what she thinks is right in nearly every book (and most of the time, she ends up saving the world).
In Robert A. Heinlein's The Rolling Stones, Buster, the youngest of the Stones, suffers from severe space sickness early in the family's trip to Mars. Roger makes plans to swing their ship back towards Luna, despite being turned down by traffic control and knowing he'd at minimum be heavily fined, and have his ship master's license revoked.
The Book of the New Sun: Severian is a Journeyman and suppose to torture targets, but he spares a woman of pain by allowing her to commit suicide after seeing what the others in his trade were doing.
The Maze Runner: Thomas, despite everyone telling him that Rule Number One of the Glade is to never go out at night, runs out while the gates are closing to help Minho and Alby.
''Brotherband has Hal and his Heron crew lose their ship and their weapons as punishment for the Andomal getting stolen on their watch. They use the time offered to hand over these possessions to jump Hallasholm on said ship to get back the Andomal.