Not since the Vietnam War more than three decades ago has the United States found itself waging a bloody conflict abroad as a fierce political argument has broken out at home over the reasons for getting into the fight in the first place and the ways of getting out.

Thursday's presidential debate crystallized the current argument. Sen. John F. Kerry (D-Mass.) portrayed the decision to invade Iraq as misguided and criticized the war's conduct. President Bush vigorously defended the mission as a necessary component of his broader anti-terrorism campaign and insisted that his battle plan will succeed.

But the exchange also highlighted the risks -- both for the candidates and for the U.S. troops deeply entangled in combat 7,000 miles away -- of having the war emerge as a hotly disputed political issue.

For Kerry, several analysts said yesterday, the challenge is to level his criticisms without sounding antiwar. Otherwise, they said, he runs the danger of contributing to a demoralization of U.S. military forces and, if elected, limiting his options for keeping troops in Iraq.

For Bush, the trick is to portray his military efforts as working without sounding Pollyannaish. Too upbeat a message could damage his credibility if conditions in Iraq deteriorate further.

"Bush needs to look like he's not being too optimistic, while Kerry has to avoid appearing too pessimistic," said Peter D. Feaver, a political science professor at Duke University.

The result so far has been a sharpened debate between the candidates about the past -- that is, how the United States reached this point in the Iraqi conflict. Less clarity has emerged over which candidate might have the better idea -- or even a different idea -- for what to do next.

The question of whether the United States should have invaded Iraq drew some of the starkest differences in Thursday's exchange between the candidates. Kerry challenged Bush's portrayal of former Iraqi president Saddam Hussein as a threat who could be dealt with no other way.

Calling the decision to go to war "a colossal error in judgment," Kerry said Bush had failed to "exhaust the remedies" of U.N. weapons inspections and had rushed into Iraq without assembling a "true alliance" of forces or devising a postwar plan.

"Saddam Hussein was a threat," Kerry acknowledged, but added: "There was a right way to disarm him, and a wrong way. And the president chose the wrong way."

Bush countered that he had pursued U.N. options as far as possible. Continued U.N. inspections, he said, would have done little good, given Hussein's notorious history of systematic deception and disregard for U.N. resolutions.

"That's kind of a pre-September 10 mentality, to hope that somehow resolutions and failed inspections would make this world a more peaceful place," Bush said.

Central to the dispute is the issue of U.S. military priorities.

The invasion of Iraq, Kerry said, diverted U.S. forces from what he called the more important mission of finding Osama bin Laden and defeating remnants of al Qaeda's terrorist network in Afghanistan.

"Iraq is not even the center of the focus of the war on terror," Kerry said. "The center is Afghanistan."

But Bush described Iraq as "a central part of the war on terror." He insisted that the United States had the forces to go after both Hussein and bin Laden.

The notion that the war on terrorism should have only one focus, Bush said, is a misunderstanding of its nature. He maintained that the ouster of Hussein marked a major achievement.

"The world is better off without Saddam Hussein," he said.

Kerry countered that the U.S. military campaign in Iraq has turned that country into a magnet for extremists, aggravating the larger effort to combat terrorism worldwide.

"Iraq was not even close to the center of the war on terror before the president invaded it," Kerry said.

But Kerry, for all his assault on Bush's approach, stopped short of suggesting that he would withdraw U.S. forces. To the contrary, he seemed in agreement with Bush that the United States, having gotten into Iraq, cannot afford to pull out before the job is done.

"We have to succeed," Kerry said. "We can't leave a failed Iraq."

This commitment to military victory will make it hard for Bush to label Kerry as an antiwar candidate. It distinguishes his clash with Bush from George McGovern's failed attempt in 1972 to unseat another Republican president, Richard M. Nixon, by promising a quick withdrawal of U.S. troops from Vietnam.

Bush warned that Kerry's criticism of the Iraq war would undermine the senator's ability to command U.S. troops or rally the world.

"I don't see how you can lead this country to succeed in Iraq if you say wrong war, wrong time, wrong place," Bush said. "What message does that send our troops? What message does that send to our allies? What message does that send the Iraqis?"

But Kerry appeared mindful of the potential impact of his criticisms on the U.S. military. He promised to keep U.S. troops well-equipped, saying they "deserve better than what" they have received under Bush. In an allusion to the Vietnam era, when protest of the war led to poor treatment of U.S. troops, Kerry made clear he wanted to avoid any such spillover.

"It is vital for us not to confuse the war, ever, with the warriors," he said. "That happened before."

How Kerry would proceed differently than Bush to ensure peace in Iraq remained unclear, however. The strategies of both candidates hinge on strengthening Iraqi security forces to supplant U.S. forces. Kerry said he would make a renewed effort to enlist the support of countries that up to now have been reluctant to get involved. He argued that he would bring greater credibility to the effort.