ST. LOUIS ― The second debate was a nasty, embarrassing mess even before it began.

Republican presidential nominee Donald Trump came here knowing that he would be hounded about audio tapes in which he brags about his own sexual predations.

Democratic nominee Hillary Clinton came here knowing that Trump would respond by bringing up her husband’s history of adultery and sexual conquest.

Never in modern American history has sex figured so centrally in a presidential debate.

And from the moment Clinton and Trump walked onstage from opposite wings, the nasty tone was set. The two candidates for the presidency of the United States met in the middle of the space, glared at each other and steadfastly refused to shake hands.

It was downhill from there: a wild descent into acid accusations of unfitness for office, threats of prosecution and denunciations of all kinds in a 100-minute town hall debate that was the most contentious ― and juvenile ― in modern history.

Roaming the stage like an aging orange tiger, Trump told Clinton she should be in jail, repeatedly called her a liar to her face, accused her husband of sexual predations and the former secretary of state of having sought to silence and punish the women involved.

Bloomberg via Getty Images Donald Trump roamed the stage as Hillary Clinton spoke Sunday.

Clinton, smiling tartly, called “Donald” unqualified for the office, dangerously ignorant, a congenital liar, a tax cheat, a racist and a bully.

In what was surely the most chilling moment of the night, Trump said that Clinton had criminally mishandled her State Department emails, should be “in jail,” and vowed, if elected, to appoint a special prosecutor to investigate her conduct in office.

Of course he had already decided that she should be in jail, so who needs a prosecutor?

Never before has one major-party U.S. presidential candidate threatened to jail his or her opponent. It is the kind of statement usually made in despotic countries, where losing candidates often end up in prison.

The town hall format allowed Trump to stalk the stage, lurking behind Clinton as she answered questions, and he muscled his way into directly confronting the Democratic nominee on issues such as her emails and her modest record of accomplishment in Congress.

He proudly admitted that he had indeed used $916 million in tax write-offs against his income, but attacked Clinton for not changing the very law he used.

Asked by a Muslim woman what he would do to reassure her community, Trump defiantly ― almost contemptuously ― told her that it was her duty to inform the police if she saw any evidence of “radical Islamic terrorism.” He almost sneered when he said it.

It was an in-your-face “politically incorrect” statement designed to warm the hearts of his core supporters on the right ― and turn off everyone else.

But, at the same time, the billionaire consistently betrayed his own ignorance – either of details of the policies he espoused, or of foreign policy matters he claimed to care about.

He fully backed Bashar Assad in Syria (and said his own vice presidential running mate, Mike Pence, was wrong to suggest otherwise), said that he knew “nothing about Russia” and claimed to know more about the Middle East than the entire Pentagon does.

Robyn Beck/AFP/Getty Images Trump and Clinton didn't shake hands before the debate, but did afterward.

In her usual plodding fashion, a smiling Clinton recited in detail her policy victories on children’s health care and other issues, talked in detail about what the U.S. should and should not do in Syria, and how Obamcare could and should be reformed.

But she met Trump’s attack lines with some of her own: accusing Trump of using foreign steel in his projects, tying him (without evidence) to Russian President Vladimir Putin and Russian hackers, insisting that he was “inciting violence” at his rallies and with his “racist lie” about President Barack Obama’s birth.

After the debate, Trump spinner-in-chief Rudy Giuliani told me that he thought his man had won the debate. “He was the aggressor,” the former mayor of New York said. “He controlled it.”

But top Clinton adviser Joel Benenson told me that Trump had repeatedly betrayed his lack of knowledge and had “thrown his own running mate under the bus” on the Syria issue.

GOP poll-taker Frank Luntz’s focus group judged Trump the winner, and it was true that in a raw animal sense the chaotic aggression of the debate ― and the freedom to move around the stage ― played to his advantage.

But other polls, including from CNN, showed Clinton winning handily.

Trump, in the end, did a better job than he had in the first debate of inciting his core voters, but did little or nothing to bring in new ones.

Trailing in the polls and in Electoral College counts, he needed to do much more than that. He swung as hard as he could ― and effectively knocked himself out.

Editor’s note: Donald Trump regularly incites political violence and is a serial liar, rampant xenophobe, racist, misogynist and birther who has repeatedly pledged to ban all Muslims — 1.6 billion members of an entire religion — from entering the U.S.