As the debate moved to security, Hillary Clinton said "there is no doubt Russia has used cyber attacks" on US organisations, while her rival Donald Trump claimed so-called Islamic State is winning the cyber war.
"We are seeing cyber attacks coming from states, organs of states. The most recent and troubling of these has been Russia," said Mrs Clinton.
"There's no doubt now that Russia has used cyber attacks against all kinds of organisations in our country and I am deeply concerned about this," she said.
Mr Trump responded: "Whether that was Russia, whether that was China, whether it was another country, we don't know, because the truth is under President Obama we've lost control of things that we used to have control of.
"We came in with the internet, we came up with the internet, and I think Secretary Clinton and myself would agree very much when you look at what ISIS is doing with the internet, they're beating us at our own game, ISIS. So we have to get very, very tough on cyber and cyber warfare," he said.
Discussions about trade policy shifted to the fight against Islamic State as Mr Trump accused Mrs Clinton of giving away information to the enemy by revealing on her website how she planned to defeat the group.
Mrs Clinton said that unlike Mr Trump, she at least had a plan for fighting Islamist militants.
Mr Trump said America had to "knock the hell out of ISIS".
Mr Trump also repeatedly insisted that he opposed the Iraq War before the 2003 US and UK invasion, despite telling radio host Howard Stern in September 2002 that he supported it.
Explaining his 2002 comments, Mr Trump said: "I said very lightly, I don't know, maybe, who knows."
Discussing nuclear weapons, Mr Trump said he "would not do first strike" but he "can't take anything off the table".
Mrs Clinton said her Republican rival was too easily provoked to serve as commander in chief and could be quickly drawn into a war involving nuclear weapons.
"A man who can be provoked by a tweet should not have his fingers anywhere near the nuclear codes," she said.
Mr Trump replied: "That line's getting a little bit old."
Mr Trump accused Mrs Clinton of leaving a trail of chaos in the Middle East during her tenure as secretary of state, in a fiery exchange.
"You look at the Middle East, it's a total mess, under your direction, to a large extent," Mr Trump said.
Mr Trump defended his comments calling long-standing alliances into question, saying nations like Japan must pay their way.
"We cannot be the policeman of the world, we cannot protect countries all over the world, where they're not paying us what we need," Mr Trump said.
In how he would handle the office of the president, Mr Trump said. "I have much better judgment than she does. There's no question about that. I also have a much better temperament than she has."
Mrs Clinton smiled back dismissively and said: Wow! Ok."
Toward the end of the debate, Mr Trump claimed Mrs Clinton does not have the "stamina" to be president, hitting at the Democrat after a recent bout of pneumonia.
"She doesn't have the look, she doesn't have the stamina," he said.
Citing her own public record, Mrs Clinton retorted tp applause: "As soon as he travels to 112 countries and negotiates a peace deal, a ceasefire, a release of dissidents ... or even spends 11 hours testifying in front of a congressional committee, he can talk to me about stamina."