Let Off by the Detective

Normally, a detective's job is to investigate a crime, question witnesses and suspects, and ultimately reveal the guilty party so the law can take over. However, sometimes over the course of the investigation it will turn out that the victim was unspeakably evil, the perpetrators' motive was unquestionably good or the reveal will cause collateral damage to others, such as the criminal's family. In this case, though all the evidence points to one particular solution, the detective will never reveal this to the authorities. Instead, the detective will either feign ignorance or confect an alternative solution, sometimes going so far as to hide the most incriminating evidence. Sometimes marks the detective as an Anti-Hero, but if done right, it's possible for this to be written as the most moral option available to the detective.

If the culprit isn't a Sympathetic Murderer, expect them to be a Karma Houdini. Particularly fiendish villains may even use this to set up a Xanatos Gambit - either the crime goes unsolved, or the detective solves it but realises they can't reveal the solution without causing tremendous pain to the innocent. Can be an example of Screw the Rules, I'm Doing What's Right.

An Ending Trope, so beware for spoilers.

Film

 * At the end of Death Wish, Lt. Ochoa figures out that Paul Kersey is the vigilante who has been killing criminals, but the District Attorney does not want the negative press that would come from prosecuting him. Because they are among the only authorities who know, they tell Paul to just get out of town, and they'll bury the evidence.
 * In Chinatown, Jake Gittes lets Evelyn Mulwray take the girl and make a run for Mexico. It doesn't work though.

Literature
"Holmes: After all, Watson, I am not retained by the police to supply their deficiencies."
 * As usual with mystery tropes, Sherlock Holmes did it first.
 * In "The Adventure of the Blue Carbuncle" Holmes lets the culprit go, although he does ensure the Countess gets her gem back and an innocent man is released from prison. He explains afterward to Watson that he feels that the thief had experienced so much fear and anguish that he won't dare try to commit another crime, and thus is more likely to become a hardened criminal if he goes to prison, whereas currently he's not a danger to anyone.


 * This also occurs in "The Adventure of the Priory School". James Wilder, the older son of the Duke of Holdernesse, plans to kidnap the Duke's younger son in order to force the Duke to change his will in Wilder's favor. Wilder hires a man called Hayes to perform the kidnapping, but Hayes murders an innocent man who tried to prevent it. Even though Wilder is guilty of kidnapping an innocent boy, conspiracy to commit kidnapping and partial responsibility for the murder, Holmes only turns in Hayes to the police, allowing Wilder to be sent to Australia to seek his fortune.
 * In "The Adventure of The Abbey Grange", after subjecting the perp to a Secret Test Holmes "appoints" Watson as jury, and they declare him not guilty by reason of self-defence. (This might be how an actual court would see it, but it would embroil the lady concerned in scandal.)
 * One more Sherlock one, "The Adventure of the Devil's Foot". The Asshole Victim is subjected to the horrific psychotropic drug he'd been using to commit murder, including his sister, whom the perp was in love with. Holmes doesn't hesitate to let him go.
 * Agatha Christie's Murder On the Orient Express is the most famous example. A man let off on a technicality after kidnapping and murdering a young girl is found dead on the Orient Express, and after investigating, Poirot announces that there are two possible solutions. The first is that an unknown assassin crept onto the train, killed the man, then slipped away again. The second is that Although the first solution is full of holes, Poirot agrees to tell the police that that is what happened, since he believes that justice has been done by the murder.
 * The 2010 adaptation raises some of the issues that have been associated with this solution- for one, Poirot is much more reluctant to let the killers off, because he is revolted by the crime and its motivation even though he admits that the victim had it coming like no other, and in other stories he has not let such a thing get in the way of the law. The other is that, given the circumstances he and the killers find themselves in, it would be perfectly possibly for them to just kill him as well before the authorities arrive and pass the killer off as a third party; the book glosses over the fact that even if Poirot did want to turn them in, he wasn't in much of a position to do so anyway as the killers had him at their mercy. In the end he still lets them off and the killers agree prior to that that murdering Poirot (and the train manager, his friend) would be a Moral Event Horizon they aren't willing to cross, so the original ending still plays out, albeit with more angst.
 * In Isaac Asimov's The Naked Sun, Elijah Baley calls a Summation Gathering and reveals that the murder victim's neighbor, a roboticist named Jothan Leebig, was planning to subvert the Three Laws of Robotics to create an army of Killer Robots. Leebig commits suicide rather than being arrested, and no one notices the fact that Leebig couldn't possibly have carried out the deed due to his intense fear of human contact. Baley admits that the victim's wife Gladia killed her husband, having been manipulated into it by Leebig, but he sympathized with her circumstances and felt she didn't deserve to be punished.
 * The Finishing Stroke is an Ellery Queen novel wherein the author/detective hero is stumped by the murder for a couple of decades. When he does finally solve the case the killer, who was an older man when he committed the murder, is truly elderly and infirm. Since Ellery doesn't want to see him spend the last few years of his life in prison, he keeps his identity secret.
 * In one of Georges Simenon 13 Mystères, investigator Joseph Leborgne didn't tell the police their case was a Suicide, Not Murder Insurance Fraud.
 * In "Murder Mysteries" by Neil Gaiman, a detective tells the story of his first case, in which the killer had a sympathetic motivation but paid the ultimate price. It's implied that he's telling the story at this time and in this place because the case has parallels to the murder he's currently working -- and that he's decided this time to let the killer off.
 * Erast Fandorin lets the Lovable Rogue Momus off in the end of Jack of Spades, mainly because he has no solid evidence against him, Momus returned everything he stole from Fandorin and his friends, and, along the way, helped him catch an Asshole Victim red-handed.

Live Action TV

 * Jonathan Creek:
 * In the episode "The Scented Room", a theatre critic who gave his act a bad review and his violent wife have a priceless painting of theirs vanish from a locked room, stolen by . The painting is returned, but Jonathan refuses to tell them where it went or who took it, partly because he sympathises with the culprit, and partly just to annoy the critic.
 * In "Danse Macabre" meanwhile, it turns out the murder was actually an elaborate suicide. Although this means that the "murderers" were still accomplices to suicide - a crime in the UK - Jonathan doesn't turn them in to the police out of obvious sympathy. It's not clear if he turns in.
 * Veronica Mars: In season two, gay students are blackmailed into giving someone money or risk getting outed. When Veronica solves the mystery, she doesn't bother calling the crook out since the student in question
 * An episode of Criminal Minds ("Riding the Lightning") inverted this. A woman was on death row for being a serial killer. The only murder she had admitted to was her son. The Behavioral Analysis Unit discovered the child was still alive; the woman had hid him from her husband, the real killer, and wanted to die herself so that her son would grow up not knowing he was descended from such people. The BAU let her be executed for the crime she didn't commit (but Hotch taunted the husband at his execution with a photo of his still living son).
 * The Columbo episode "Forgotten Lady" has guest star Janet Leigh portraying an aging movie star who plans a comeback. Her physician husband refuses to fund it, and she kills him. There is some evidence that she has quickly forgotten what she did (along with other recent events), which Columbo confides to her dear friend and former co-star. She becomes distraught at Columbo's persistent investigations, and the friend confesses to the murder to soothe her. Columbo knows that she has no more than a month or so to live and assures the friend that he'll take his time disproving the false confession until she dies.
 * In the Law and Order episode "Deadbeat" McCoy and Ross realize that a woman killed her child support dodging ex-husband to . Because she's the mother of a terminaally ill boy, Jack decides to indefinitely delay her prosecution.
 * In one CSI New York episode a man was killed at a local university and the forensic evidence destroyed using information gained at a lecture given by one of the cast. After discovering that the deceased was a repeat stalker that had driven one woman to suicide and followed another across multiple states despite a name change they managed to track down the stalkee-turned-killer, but while they did arrest her they made a point to tell her that without a confession there was no way to convict her on such flimsy circumstancial evidence.
 * In another episode, Stella warns off a suspect who was her former foster sister, after the woman killed a man who'd molested her. Stella should have arrested her but instead tell sher she'll be back the next day to make the arrest, knowing full well the woman would probably be gone by then.

Newspaper Comics
"Calvin (as Tracer Bullet): "I had figured out who trashed the dame's living room, but since she wasn't my client any more, I felt no need to divulge the information. Besides, the culprit happened to be a buddy of mine. I closed the case."
 * Parodied in Calvin and Hobbes in one of his "Tracer Bullet" film-noire fantasies where someone broke Mom's lamp.

Hobbes (holding a football): "I guess we should've played outside, huh?""

Video Games

 * In Phoenix Wright: Justice for All, the Nonstandard Game Over in the final case involves you being blackmailed into doing this. In this case, though, your assistant has been kidnapped by an assassin hired by the culprit, who'll kill her if the culprit is found guilty. To get the Golden Ending,.
 * In Deus Ex Human Revolution you have the option of doing this in a few quests. Typically by deciding that the person you're after is in the right or just an Unwitting Pawn (examples include the anti cyborg terrorist from the first story mission and the rogue Belltower unit from the sidequest in the second visit to China).