(CNN) -- America's contentious and costly war in Iraq officially ended Thursday with an understated ceremony in Baghdad that contrasted sharply with its thundering start almost nine years ago.
U.S. troops lowered the flag of command that flew over the Iraqi capital, carefully rolled it and cased it in camouflage in accordance with Army tradition.
The quiet ceremony, under a bright Iraqi sun, was the opposite of the nighttime "shock and awe" bombardment of Baghdad that launched the war against Saddam Hussein in March 2003.
Justified by President George W. Bush on the grounds that Hussein was seeking weapons of mass destruction that he could share with terrorists such as al Qaeda, the invasion cased deep divisions in America and around the world.
After that, men and women from Maine to Hawaii began crossing the border into Iraq -- and began dying or coming home with lifelong injuries.
Hussein's regime proved easy to topple, but no weapons of mass destruction were found, and the United States and its allies were left occupying a country where they were not greeted as liberators, despite the prediction of Bush's vice president, Dick Cheney.
Iraq erupted into sectarian violence, leaving U.S. troops to try to contain what threatened to become a civil war. Improvised explosive device became a household term, traumatic brain injuries a signature wound of the war.
Defense Secretary Leon Panetta, who flew into Baghdad for Thursday's flag-lowering ceremony, recalled that when he visited in 2006 as a member of Bush's Iraq Study Group, "sectarian violence was skyrocketing, and it seemed as if nothing was working."
But, he said, "After a lot of blood spilled by Iraqis and Americans, the mission of an Iraq that could govern and secure itself has become real."
On Thursday, the Iraq war officially ended as President Barack Obama described it: not with a final battle but with a final march home for U.S. troops.
In all, the United States spent more than $800 billion in Iraq.
Panetta reflected on a greater cost.
He said the United States was "deeply indebted" to all Americans in uniform. Nearly 4,500 of them were killed in this war, more than 30,000 wounded.
And he hailed the advances made in Iraq since Hussein was ousted.
"This is a time for Iraq to look forward," he said. "This is an opportunity for Iraq to forge ahead on a path to security and prosperity. We owe it to all of the lives that were sacrificed in this war not to fail."
No one knows how many Iraqis have been killed since March 2003, but the independent public database Iraq Body Count has compiled reports of more than 150,000 between the invasion and October 2010, with four out of five dead being civilians.
Thousands of other Iraqis struggle to cope with lives marred by war. For them, the battle goes on as the Americans leave behind a fragile nation struggling to establish democracy, struggling to establish stability.
Violence still claims innocent lives in Iraq. People are frustrated with the lack of electricity. Baghdad is awash in trash. No one can predict Iraq's future without the presence of Americans.
"As long as there are assassinations and explosions from time to time in this country, then of course I have fears," said ministry of transportation employee Abu Hadeel. "When I walk in a crowded street, I have concern of any sudden explosion. There are no guarantees."
Student Moutazz Sami said Iraq was not prepared militarily or politically to handle challenges. But businessman Ethar Mohammed said "every beginning has an end."
"The political divisions are huge and no one knows what will happen after December 31," the date by which American troops must leave, said Iraqi journalist Mina al-Oraibi, assistant editor-in-chief of Asharq Alawsat newspaper in London.
All U.S. troops must be out of Iraq by the end of this month after Washington and Baghdad failed to agree on terms under which they could remain.
At the height of the war in 2007, when Bush ordered a so-called surge, more than 170,000 American troops were stationed in Iraq, living on more than 500 bases and outposts across the nation.
As of Tuesday, only 5,500 American troops remained. A senior defense official traveling with Panetta said that some troops -- perhaps 3,000 to 4,000 -- will remain in Kuwait for a certain period of time but said the details have not been worked out with the Kuwaitis.
Only half of Americans think their nation achieved its goals in Iraq, according to a CNN/ORC International poll conducted last month. Still, 61% favored the withdrawal of all troops by the end of the year. And 68% said they opposed the war in Iraq.
Iraqis, on the other hand, are worried that the United States wants to disengage from their country entirely, al-Oraibi said, pointing out that Obama came to office partly on the strength of his opposition to the war and sent Vice President Joe Biden to visit recently rather than coming himself.
But Brett McGurk, a former adviser to three U.S. ambassadors, pointed out that U.S. disengagement has been a process, rather than a sudden action. Iraq, he said, has been in charge of its own security since 2009.
"It's not like we were controlling Iraq's security situation last week, and now we're suddenly leaving," he said. "We haven't had troops in Baghdad for over two years."
Gen. Martin Dempsey, chairman of the Joint Chiefs of Staff, explained in practical terms what the end of the U.S. military mission meant.
Departing from his prepared text, he said he had been able to fly into Iraq on this occasion simply because he wanted to do so.
"The next time I come here, I'm going to have to be invited by the Iraqi government, and I kind of like that," Dempsey said before concluding his speech with thanks and a blessing in Arabic.
Secretary of State Hillary Clinton said the United States will help the people "realize their own ambitions for a free and sovereign Iraq." It also will work closely with the Iraqi government to ensure the safety of U.S. civilians staying in the country, she said.
"I think it's understood this is one of the most challenging missions that the State Department has ever led, but we've had a great deal of thought given to what needs to be accomplished," Clinton said in Washington.
Back home, many of those Americans who sacrificed in Iraq harbor mixed feelings about the war.
But if Iraq can emerge as a free and democratic nation, every American soldier should feel proud, said retired Army Gen. Mark Kimmitt.
"If that's the case, then these soldiers can say, yes, indeed, they won," he said. "Every soldier and their families should walk away extremely satisfied and proud of what they accomplished and what they left behind. I just hope it can remain that way."
Obama laid out that same message as he welcomed home returning troops Wednesday at Fort Bragg, North Carolina.
"Because of you, because you sacrificed so much for a people that you had never met, Iraqis have a chance to forge their own destiny," Obama said. "That's part of what makes us special as Americans. Unlike the empires of old, we did so not for territory or for resources. We do it because it's right.
Obama said there was no fuller expression of U.S. support for self-determination than its withdrawal from Iraq. That, he said, speaks volumes for the American people.
This article is based on reporting by CNN's Mohammed Tawfeeq and Arwa Damon in Baghdad, Moni Basu in Atlanta, Zain Verjee in London and Tom Cohen in Washington.