Updated

Donald Trump and Hillary Clinton slammed each other over the Iraq War and the fight against ISIS at a national security forum Wednesday, with the Republican nominee also appearing willing to allow undocumented immigrants wishing to serve in the military to remain in the U.S.

Though Trump and Clinton did not appear onstage together at the USS Intrepid museum in New York, the NBC News forum was a debate in all but name and came fewer than three weeks before the candidates' first debate.

Trump's response to a question about whether illegal immigrants who plan to serve in the military can stay in America marked another apparent shift for the Republican nominee, who caused outrage during the GOP primary with his call to deport all illegal immigrants.

"I think that when you serve in the armed forces, that's a very special situation, and I could see myself working that out," Trump said. "We need to be careful and vet carefully, but it would be a special circumstance, yes."

Trump leveled unusual criticism against America's military leaders, saying the generals have been "reduced to rubble" during President Barack Obama's administration. He also suggested he would shake up the military's top ranks if he wins in November, saying there would probably be "different generals."

Trump remained persistently non-commital 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."

Clinton took the stage first by virtue of a coin flip, and immediately faced a barrage of questions from moderator Matt Lauer about her email use at the State Department, where she used a personal email address and a private server.

The former secretary of state repeated her claim that none of the emails she sent through the server was marked "classified," "top secret," or "secret." However, she also acknowledged that "it was a mistake to have a personal account ... I make no excuses."

At times, Clinton grew visibly irritated with the repeated focus on her past actions, saying "I'm asking to be judged on the totality of my record."

Later in her segment, Clinton described her 2003 Senate vote to authorize military action in Iraq as a "mistake" and criticized Trump for supporting military action against Iraq in a 2002 interview on the Howard Stern radio show. She vowed that "we are not putting ground troops in Iraq ever again" to help defeat ISIS "and we are not putting ground troops in Syria ever."

"I was totally against the war in Iraq," Trump said in response. "I said it would destabilize the Middle East, which it has."

Trump accused Clinton of having a "happy trigger [finger]" regarding overseas military intervention, specifically criticizing her response to Libya's uprising against Muammar Qaddafi and subsequent civil war.

Clinton defended her support for U.S. military intervention in Libya, despite the chaos that has consumed that country since then.

"Permitting there to be an ongoing civil war in Libya would be as threatening and as dangerous as what we are seeing in Syria," she said.

Trump also spoke glowingly of Russian president Vladimir Putin, praising him for having "great control over his country." The real estate mogul added that if Putin "says great things about me, I'm going to say great things about him." Trump also claimed, however, that Putin's compliments would not influence his decision-making as president.

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. She drew an implicit contrast with Trump when asked for the most important quality a commander in chief must possess.

"Steadiness, an absolute rock steadiness," she said, "mixed with strength to make the hard decisions."

The Associated Press contributed to this report.