Hillary Clinton defended her history of handling classified information, while Donald Trump was grilled on his support for Russia during Wednesday night's highly anticipated national security forum.

The U.S. presidential candidates appeared back-to-back on the same stage for the first time during NBC's "commander-in-chief" forum, answering questions about national security in front of a live TV audience aboard the decommissioned USS Intrepid, which is now a floating museum in New York.

The political rivals faced tough questions from NBC's Matt Lauer as well as veterans and active-duty troops in the audience. The event served as a preview for voters of the candidates' trio of debates later this fall.

Both Lauer and audience members grilled Clinton over her use of a personal server for government emails while she was secretary of state — an issue that has long dogged the Democrat's campaign.

Clinton speaks with Today show co-anchor Matt Lauer at the NBC commander-in-chief forum, where she was grilled about her use of a personal email server while she was secretary of state. (Andrew Harnik/Associated Press)

Both the FBI and U.S. Justice Department have cleared Clinton of criminal wrongdoing in the email scandal, but FBI Director James Comey has called her behaviour "extremely careless."

Clinton acknowledged that using the personal server was "a mistake" and something she "should not have done."

Democratic presidential candidate answers questions during national security forum 2:08

Still, Clinton maintained she never mishandled classified information.

"I communicated about classified material in wholly separate systems," she said. "I did exactly what I should have done and I take it very seriously — always have, always will."

Iraq war

When asked about her 2002 vote to send troops to Iraq, Clinton admitted that, too, was a mistake.

She vowed never again to send ground troops into Iraq, adding the same goes for Syria.

Clinton said she views "force as a last resort, not a first choice," and then argued that her opponent has not taken responsibility for his support of the war.

Hillary Clinton talks security and defence in New York forum 0:40

Trump said during the forum that he was "totally against the war in Iraq," because he worried it would destabilize the Middle East.

That position is contradicted by an interview Trump did with Howard Stern in September 2002, in which he was asked whether he supported the invasion and responded, "Yeah, I guess so."

"I always said 'take the oil,' one of the benefits we would have had if we took the oil [from Iraq] is ISIS would not have been able to take oil and use that oil to fuel themselves," Trump told Lauer.

Trump praises Putin

Trump, meanwhile, reiterated his position that the U.S. should co-operate more closely with Russia — a country he said "wants to defeat ISIS as much as we do."

Trump has been criticized in the past for seeming to heap praise on Russian President Vladimir Putin and other strongmen. Putin has returned in kind, calling Trump "a colourful and talented man."

Questioned by Lauer, Trump defended his kind words about Russian President Vladimir Putin. (Evan Vucci/Associated Press)

The Republican candidate was unapologetic when questioned about this by Lauer, saying he was happy to take a compliment from Putin.

"If he says great things about me, I'm going to say great things about him," Trump said.

Trump added that he believes Putin makes a better leader than U.S. President Barack Obama.

'If he says great things about me, I'm gonna say great things about him' 2:41

Ahead of the forum, Trump rolled out a new plan to boost military spending by tens of billions of dollars, including major increases in the number of active troops, fighter planes, navy ships and submarines. The Republican also said that, if elected, he would give military leaders 30 days to formulate a multi-pronged plan to defeat ISIS.

"Under the leadership of Barack Obama and Hillary Clinton, the generals have been reduced to rubble, they have been reduced to a point where it's embarrassing for our country," said Trump, adding that WWII general George Patton would be "spinning in his grave" or the inability to combat ISIS.

During Wednesday's event, Trump remained persistently vague about his plans for defeating ISIS, insisting that he privately has a blueprint for taking on the terror group but wanted to remain "unpredictable."

"I have a very substantial chance of winning," he said. "If I win, I don't want to broadcast to the enemy exactly what my plan is."

Republican presidential candidate talks defence in New York 2:01

Clinton has spent much of the summer trying to paint Trump as ill-prepared to be commander-in-chief and too unpredictable to make decisions that put American service members in harm's way.

Her case has been bolstered by numerous Republican national security experts who have spoken out against their party's nominee, including former defence secretary William Cohen, who announced his support for Clinton on Wednesday.

Said Clinton: "They know they can count on me to be the kind of commander-in-chief who will protect our country and our troops, and they know they cannot count on Donald Trump."

"They view him as a danger and a risk."