BAGHDAD – The U.S. military on Wednesday marked the end of its combat mission in Iraq amid a series of conflicting messages that underscored the mixed feelings many here, both American and Iraqi, have toward a seven-and-a-half-year effort that cost tens of thousands of lives but left the political outcome undecided.

“The problem with this war for, I think, many Americans is that the premise on which we justified going to war proved not to be valid, that is Saddam (Hussein) having weapons of mass destruction,” Defense Secretary Robert Gates told reporters as he hopped from one stripped-down U.S. military base to another greeting American troops.

“So when you start from that standpoint, then figuring out in retrospect how you deal with the war — even if the outcome is a good one from the standpoint of the United States — it will always be clouded by how it began.”

Iraqis, too, expressed ambivalence about the U.S. declaration that combat operations would be giving way to “partnering efforts” led by Iraqis and would lead to the complete withdrawal of the remaining 50,000 American troops by the end of 2011.

“I am torn,” said Widad Hameed, a retired high school teacher. “I am strongly opposed to the presence of foreign troops on Iraqi sovereign soil — and therefore hope to see them leave as quickly as possible. This is on principle.

“But on the other hand, I am afraid of what might happen after they leave. I have no great faith in the abilities of the (Iraqi Security Forces) and feel that the chaos in our political situation will be reflected upon the security scene as the politicians slug it out and violence will rise and the people will pay.”

On Wednesday, Gates, Vice President Joe Biden and other top military leaders, including Adm. Michael Mullen, the chairman of the Joint Chiefs of Staff, presided over a ceremony that passed command of U.S. forces from Army Gen. Raymond T. Odierno to Gen. Lloyd Austin. Operation Iraqi Freedom became Operation New Dawn, and the American military mission here became one of training their Iraqi counterparts as U.S. forces draw down to zero.

Hundreds of troops gathered for the hourlong ceremony inside a palace at Camp Victory. As Iraq’s ministers of defense and interior looked on, Biden declared an end to the U.S. combat mission and said that the U.S. sought an “economically prosperous and stable” Iraq.

In his speech, Odierno said he’s confident that Iraqi security forces, now numbering 660,000, can protect the country.

Austin, in his speech, said the next phase is the start of an “enduring relationship” between Iraq and the U.S.

Everyone, however, remained cautious about the road ahead.

A senior commander told reporters traveling with Gates that while combat operations are officially over, U.S. forces partnered with Iraqis could still face fire — and would return it.

When Gates traveled to Ramadi by helicopter, his staff wore helmets and flak vests. During a question-and-answer period with troops, Gates told soldiers they still deserved combat pay, even as he told them they were now trainers, not fighters.