When the only possible way for a lawyer to save his client is to badger a confession out of a witness on the stand in the courtroom. Subtrope of Perp Sweating. Frequently stems from Accusing The Witness. The result is usually a Motive Rant. The first step is often to Pull the Thread.
This is a popular way to avert the Fridge Logic inherent in Conviction by Contradiction; in this case, catching the witness in a lie doesn't prove they're the culprit; it just convinces them the gig is up so they'll convict themselves by confessing. When played straight, this one is also a subtrope of Hollywood Law — defense attorneys often discredit witnesses through various means and posit other potential suspects (named or unnamed), but forcing a confession is difficult to do without being disbarred. In the United States and the United Kingdom, forcing the defence to prove that someone else is guilty is Shifting The Burden Of Proof (in a criminal case), but this is rarely mentioned in media, as it removes the "solve the mystery" element.
Perry Mason's success rate was parodied in one episode of "Little Annie Fanny". As soon as the police announced that detective "Mason Dixon" was investigating, some random nearby onlooker would scream out "I confess! I confess! I haven't got a chance if Mason Dixon is on the case!"
In Youngblood: Judgment Day, Toby King's relentless pursuit of the details behind a book missing from Riptide's room after her murder, gradually uncovering an intimate connection between a certain member of Youngblood and that book, eventually causes Sentinel to fly into a fit of rage and attack him. He grabs at the book and curses King for ruining his plan, outing himself as the murderer.
Subverted in the film Catch Me If You Can — con artist Frank Abagnale Jr. attempts to use this technique while posing as a lawyer, having seen Perry Mason do it on TV; after his climactic accusation, the judge sternly informs him that he is at a preliminary hearing and neither the defendant nor the jury are present.
Subverted in Bananas when Fielding Mellish gets a key witness against him at his trial to tearfully confess that she was lying ... even though he's gagged and tied to a chair.
The climax of A Few Good Men is probably the Trope Codifier: Danny Kaffee pins the futures of both his clients and his own to the hope that his final witness - Colonel Jessop - will confess.
In Young Mr. Lincoln, Abraham Lincoln produces an almanac that proves the witness couldn't have seen the murder by moonlight as said witness had claimed. Lincoln then badgers said witness into confessing the murder in open court. This is allegedly based on a real incident.
Invoked in Wild Things, where the witness' breakdown in court is staged to make the trial fail.
Suspect, in which Cher plays a lawyer defending a deaf-mute Vietnam veteran (Liam Neeson) on a murder charge, may have the über-example; in the climax she unmasks the real murderer who happens to be the very judge presiding over the trial!
I have always secretly wanted to be a lawyer. I could picture myself in a major criminal case, getting the best of my opponent through clever verbal sparring and shrewd courtroom maneuvers: Me: So, Mr. Teeterhorn, you're telling us that you "can't recall" why you happened to bring a flame-thrower to the bridge tournament? Witness: That's right. Me: Well, perhaps THIS will help you refresh your memory. Witness: NO! GET THAT THING AWAY! OUCH! IT'S BITING ME! Opposing Attorney: I object, Your Honor! Mr. Barry is badgering the witness! Me (coolly): Your Honor, as these documents clearly prove, Rex here is a wolverine. Judge (examining the documents): Okay, I'll allow it.
In Primal Fear, this is set up by lawyer Martin Vail to prove Aaron Stampler's innocence. The prosecution badgers Aaron in an attempt to get him to confess, which causes Aaron's split personality to show up and attack her.
Judge Dee sometimes does this, occasionally even using torture, and he's the judge. Justified in that convictions in his setting (AD 600s China) had to be obtained through confessions. Some villains would hold out even when incontrovertible proof was being displayed.
Almost every episode of Perry Mason ever made. In one of the TV movies (late 80s-early 90s), a middle-aged woman's alibi involved changing a flat tire. Mason has a worker demonstrate how lugnuts are tightened at the shop using an air wrench, and invites her to show the court how she was able to remove them without power tools. She couldn't. (This was itself a use of Conviction by Counterfactual Clue; if it really was impossible to remove lugnuts that had been tightened with an air wrench, no one would be able to change a tire except a mechanic with an air wrench.)
Matlock almost always proved his client's innocence by interrogating the real killer in court; usually not by getting an actual confession, though.
Running Monty Python's Flying Circus character Mr. Bartlett tries this sort of thing sometimes (even on parking offences), but quickly gets sidetracked, as even he has no idea what his point is. He turned out to be right, when one of his character witnesses was revealed not to be Cardinal Richelieu at all, although it wasn't Bartlett who figured this out.
Law & Order doesn't usually trigger a simple confession: Mason Moments usually set up either the Mandatory Twist Ending ("Yeah, I did it. But you were wrong about why!") or the Red Herring Twist ("He didn't do it. I did. Really.") Also, more often than not the lawyer will be stopped by an objection before he can extract his confession.
Jack McCoy set a witness up to be Perry Masoned by the defense counsel in the episode "Homesick."
One particularly memorable three-parter ("D-Girl"/"Turnaround"/"Showtime") involved a defendant who was a famous movie director with a powerful legal team that had managed to stymy most of McCoy's usual legal wrangling. When McCoy eventually managed to get him on the stand, however, he essentially goaded the director by playing his ego with the knowledge that the victim, his ex-wife and producer, had basically wrecked his career by spitefully blocking his desired projects and forcing him to work on films that were beneath him. The director eventually explodes, grabs the murder weapon and screams "That vindictive bitch, I could have made something —" before he calms down enough to realize he's been lured into this trope.
The character Speedo, in That Mitchell and Webb Look, is a parody of this in his prosecuting style: "Did you kill that woman?! Did you kill that woman?! Did you kill that woman?!", which is entirely ineffective until he pulls out a gun and shoots it above the witness' head, at which point he agrees "Yes! Yes whatever you say!"
The team on The Practice used this technique so much that they referred to it as "Plan B". They became quite infamous for it.
The Practice example is generally a subversion as the witness they accuse is almost never guilty and the tactic is really just a ploy to create reasonable doubt for clients that they know ARE guilty.
Subverted in the JAG episode "Killer Instinct", because lead counsel Harmon Rabb knows that the defendent is too smart to confess on the stand in the usual Perry Mason style. It's only when co-counsel Bud Roberts obfuscates stupidity that the defendent makes a confession in an outburst of rage.
Done in an episode of Harry's Law when a mother was convinced of killing her newborn baby, born without a brain. Harry, the mother's lawyer, took to accusing a nurse who had been attending the birth of being the real killer (noting that, for example, the baby's neck had been snapped expertly, by someone who had medical training), and the nurse broke down and confessed.
In an episode of The Jack Benny Program (1961), Jack gets a ticket for a noisy rooster. He then has a dream where he is on trial for murdering the rooster. He employs the greatest lawyer ever, Perry Mason (played by Raymond Burr in a terrific comedy turn) but dream Mason turns out to be an idiot (he tries dressing as Abraham Lincoln to sway the judge) and is soundly trounced by the guy who says "Yeeeeeeesssssss". Mason even winds up getting himself to confess that he was the one who really murdered the rooster at the end.
The title character of Phoenix Wright: Ace Attorney does this in nearly every single case, apropos to his role as a Perry Mason stand-in. He misses the mark in case 2-4: the person he badgers is really innocent, and his client was actually a Magnificent Bastard/Sociopath who hired an assassin and was planning to blackmail him. In fact this is directly called out by Godot in the final case of the third game. Even after Phoenix proves that his client is innocent through a very convoluted set of explanations, Godot insists that the trial must continue because they haven't found out who the culprit is yet. And everyone just goes with it even though it leads to his own conviction.
The same thing happens in the third case of the first game, where Phoenix proves his client couldn't have committed the murder beyond a shadow of a doubt about halfway through the case, but the trial must continue because the actual culprit hasn't been exposed. In this case, it plays off more like the trial becoming an ongoing investigation - neither the prosecution nor the judge seem to seriously think the defendant is guilty any more, and seem genuinely curious about the truth, but your client still goes to jail if you fail.
Though one case has Phoenix concerned that even if he does get his client acquitted, the real killer might still go free, so it's clearly not always an either/or scenario.
Reportedly at least partially Truth in Television in Japan. The seemingly ludicrous success rates of convictions the fictional prosecutors hold aren't as rare as one might hope, and Phoenix's apparent high success rate would be thought just as ludicrous in Japan, and his near poverty is not a far cry from reality.
Related: Shu Takumi has said that the MASON System in the fourth game is a reference to Perry Mason.
We also get three subversions in Apollo Justice: Ace Attorney. The first case only worked because Phoenix forged some evidence (that Kristophcouldn't reveal without admitting to stealing the original evidence and committing the crime), the third case only worked because Apollo convinced the accomplice that you can't be killed for smuggling in the US/Japan and so he had no reason not to talk, and the fourth case had to be done as a Jury trial as it was impossible to have enough evidence to pin the crime on Kristoph. The jury trial runs on reasonable doubt, which is enough to save the defendant.
Funnily enough, The Movie subverts this several times, in order to be a Pragmatic Adaptation. The most notable instance is during the trial of Redd White. Phoenix is able to use evidence to prove that White was in the room, and then demands that he confess to killing Mia. White insists that Phoenix can only prove that he'd broken into the room on the night of the murder, and not that he actually committed the murder. The judge admits that this is true, but still declares Maya Not Guilty because White's initial testimony was clearly a lie.
This trope is subverted in Dual Destinies. Case 4 ends without Phoenix identifying the real murderer, only having done enough to prove that it could not be his client though Athena is immediately arrested due to incriminating evidence. The killer is not identified until near the end of Case 5.
In the 1st Degree plays with this trope. Certainly you, the prosecutor, can try to badger the witness into confessing. However, it does not seem to work very much.
There is an obscure text adventure called Perry Mason: The Case of the Mandarin Murder. Getting the best ending requires you to do this.
Lisa and Bart get Sideshow Bob to confess to rigging an election by suggesting he wouldn't be smart enough to do it.
Sideshow Bob: Only I could have engineered such a masterpiece of electoral fraud!
Wiggum tries to get Homer and Marge to confess to murder by repeatedly shouting "Did you do it?" at random points in his questioning. After the interrogation, he admits it never works... after Homer uses the same method on him to get him to admit thus.
During his 1983 trial for the murder of a Maryland police officer, Harlow Brian Sails broke down on the witness stand during cross-examination and confessed to the killing. News reports at the time called it a "Perry Mason moment."