Republican presidential nominee Donald Trump said, "I'll keep you in suspense," when answering a question about the tradition of accepting the results of presidential elections. (The Washington Post)

A defiant Donald Trump used the high-profile setting of the final presidential debate here Wednesday night to amplify one of the most explosive charges of his candidacy: that if he loses the election, he might consider the results illegitimate because the process is rigged.

Questioned directly as to whether he would accept the outcome should Democratic nominee Hillary Clinton prevail on Nov. 8, Trump demurred. “I will keep you in suspense,” the Republican nominee said. Clinton called Trump’s answer “horrifying,” saying he was “talking down our democracy.”

After a sober start, the candidates shifted gears into a series of fiery exchanges over their fitness to serve as president and character traits. But over the course of the third and final debate, they delved deeper into their substantive differences than they did in the first two forums and offered a clearer contrast in the directions they would take the country. They drew sharp distinctions on the economy, trade, terrorism, immigration and hot-button social issues including abortion and guns.

Russian President Vladimir Putin loomed as an unseen third presence onstage. Clinton and Trump sparred over which of them would be more effective as commander in chief in dealing with his aggression and Russian cyberattacks. Clinton labeled Trump as Putin's “puppet” — prompting Trump to snap back, “You’re the puppet!” — while Trump charged that Putin had “outsmarted and outplayed” her when she was secretary of state.

Here are key moments from the third and final presidential debate between Democrat Hillary Clinton and Republican Donald Trump, Oct. 19, in Las Vegas. (Sarah Parnass/The Washington Post)

After Clinton cited the findings of 17 U.S. intelligence agencies that the Russian government had committed espionage — including by hacking the emails of Clinton campaign chairman John Podesta — to interfere in the U.S. election, Trump said he did not agree with that conclusion.

“Hillary, you have no idea,” Trump said. “Our country has no idea.”

Clinton and Trump clashed intensely about each other’s character deficiencies in an urgent bid to persuade undecided voters just 20 days before Election Day and as people in many states already have begun casting ballots.

Trump was trying to present himself in a more presidential light than at the other two debates, but at times he could not contain his impulses to jab and insult.

As Clinton was needling Trump for not paying taxes, Trump interjected, “Such a nasty woman.”

The animus between the two had reached such a critical mass that the candidates dispensed with the traditional gesture of shaking hands, before and after the debate.

Trump responded angrily to a question about the chorus of women who have stepped forward in recent days to accuse him of unwanted kissing and groping, in some cases recalling episodes dating back decades. “I didn’t know any of these women,” Trump insisted, dismissing all of their stories as “lies.”

Clinton sought to claim the moral high ground by recounting Trump’s recent mockery of the women’s appearances and physiques on the campaign trail.

“Donald thinks belittling women makes him bigger,” Clinton said. “He goes after their dignity, their self worth, and I don’t think there’s a woman anywhere who doesn’t know what that feels like. We now know what Donald thinks, what he says and how he acts toward women. That’s who Donald is. I think it’s up to all of us to demonstrate who we are.”

Trump’s retort: “Nobody has more respect for women than I do.”

In the debate hall, the audience laughed, prompting moderator Chris Wallace, of Fox News Channel, to admonish them. “Please, everybody,” he said.

The 90-minute debate, held on the sprawling campus of the University of Nevada at Las Vegas, addressed a variety of issues that have received scant attention on the campaign trail, such as the Supreme Court and abortion rights.

The debate opened with a discussion of one of the most consequential decisions awaiting the next president: filling at least one vacancy on the Supreme Court. Clinton cast herself as a champion for progressive values, saying she would appoint justices who would defend women’s rights and gay rights and help to overturn the Citizens United ruling that has opened the floodgates to money in politics.

“I feel strongly that the Supreme Court needs to stand on the side of the American people, not on the side of the powerful, corporations and the wealthy,” Clinton said.

Trump said he would appoint conservative justices who would be strict constitutionalists — “so, so important, the Constitution the way it was meant to be.” And he accused Clinton of wanting to appoint justices who would severely restrict gun rights, saying the Second Amendment is “under absolute siege.”

In her retort, Clinton noted that because she lived in Arkansas for 18 years and represented Upstate New York in the Senate, she has an appreciation for gun traditions. “But I also believe that there can and must be reasonable regulation,” Clinton said.

Clinton’s agenda of gun restrictions is especially popular among suburban women, who are among the key swing demographics in this election.

Clinton and Trump sparred intensively over abortion rights, with Trump acknowledging that if he gets two or three appointees to the Supreme Court, the landmark Roe v. Wade decision would be overturned “automatically.”

Trump went on to describe late-term abortion procedures in graphic language, suggesting that many women end their pregnancies in the final one to four days. “You can take the baby and rip the baby out of the womb,” he said.

Clinton used the moment to make a gender-based argument, telling Trump: “You should meet with some of the women I’ve met with, women I’ve known over the course of my life. This is one of the worst possible choices that any woman and her family could possibly make. . . . The government has no business in the decisions that women make with their families.”

One of the sharpest differences between the candidates was on immigration and border security. Trump tried to put Clinton on the defensive, saying the country would fall apart if the border with Mexico is not strengthened.

“We have no country if we have no border,” Trump said, vowing to build a wall. “Hillary wants to give amnesty. She wants to have open borders.”

Expounding upon the influx of illegal drugs into the United States, Trump used a Spanish word in declaring, “We have some bad hombres here and we’re going to get them out.”

Clinton said she opposes mass deportations, as Trump has proposed, because “I don’t want to rip families apart.” And she portrayed Trump as a hypocrite because he has used undocumented workers to grow his real estate empire, including to build Trump Tower, his iconic showpiece in New York.

Clinton also accused Trump of getting weak in the knees when he met with Mexican President Enrique Peña Nieto in Mexico City this summer because he did not bring up his vow that he would make the Mexican government pay for the border wall.

“He choked,” Clinton said. “And then got into a Twitter war because the Mexican president said, ‘I’m not paying for that wall.’ ”

Trump seemed to argue for a hands-off policy in Syria, effectively conceding that the rebel-held portions of Aleppo — which are under heavy bombardment from Syrian government forces and their Russian allies — were already lost. “It has fallen, I mean, from any standpoint. What do you need, a signed document? I mean, from any standpoint,” Trump said.

He criticized Syrian leader Bashar al-Assad as “a bad guy,” but praised him for outsmarting President Obama and others who had called for Assad to step down. “He’s just much tougher, and much smarter, than her and Obama,” Trump said.

In the end, Trump’s argument for U.S. policy in Syria was to leave Assad alone, or seek to partner with him and the Russians to fight the Islamic State.

“He’s a bad guy. But you may very well end up with worse than Assad” if he was ever deposed, Trump said. “If she did nothing, we’d be in much better shape.”

Trump again and again tried to cast Clinton as corrupt, saying the global charitable foundation run by her family is actually “a criminal enterprise” because it has accepted millions of dollars from foreign governments and multinational corporations.

Clinton defended the foundation’s work and argued that Trump’s charitable endeavors often work to his own benefit.

“I’d be happy to compare what we do with the Trump Foundation, which took money from other people to buy a 6-foot portrait of Donald,” Clinton said, referencing a report in The Washington Post. “I mean, who does that?”

The dynamic of the presidential race has reversed since the two candidates met on Sept. 26 for their first debate. At that point, Trump was cutting into Clinton’s lead in the polls and surveys indicated that Trump’s supporters were more enthusiastic than hers.

Though both campaigns have hit bumps since then, Clinton has moved ahead in the national polls and has a lead in nearly every swing state as well. Trump’s lead has eroded even in states that previously seemed safe. At least one recent poll has shown Trump behind in three states won by GOP nominee Mitt Romney in 2012: Georgia, Arizona and Utah.

The election has taken a strikingly personal and disturbing turn in recent weeks, as Trump has escalated his attacks on Clinton and her family while responding to scrutiny over his own treatment of women. Trump has assailed former president Bill Clinton’s past marital indiscretions and has accused him of sexually assaulting women.

In the hours before the debate, Trump signaled that he would aggressively prosecute long-held grievances against the Clintons in a play to his base. Trump invited several controversial guests to sit in the audience for the debate, including Malik Obama, the president’s half brother and an avowed Trump supporter.

Trump also invited Pat Smith, the mother of an American killed in the 2012 attacks on U.S. diplomatic buildings in Benghazi, Libya — during Hillary Clinton’s tenure as secretary of state. Smith delivered one of the more emotional speeches at the Republican National Convention this summer, blaming Clinton for the death of her son.

Another Trump guest was Leslie Millwee, who recently accused Bill Clinton of sexually assaulting her in 1980. Millwee went public with her allegations earlier Wednesday via Breitbart, the conservative website that was run until recently by Trump campaign chief executive Stephen K. Bannon. Her accusations were widely circulated within the hard right’s online community.

David A. Fahrenthold and Jose A. DelReal in Washington contributed to this report.