After nearly nine years, 4,500 American dead and 100,000 Iraqi dead, U.S. officials formally shut down the war in Iraq - a conflict that Defense Secretary Leon Panetta said was worth the American sacrifice, because it set Iraq on a path to democracy.
Panetta stepped off his military plane in Baghdad Thursday as the leader of America's war in Iraq, but will leave as one of many top U.S. and global officials who hope to work with the struggling nation as it tries to find its new place in the Middle East and the broader world.
Bombings and gun battles are still common. And experts are concerned about the Iraqi security force's ability to defend the nation against foreign threats.
In addition to the dead, the war left 32,000 Americans wounded and cost the U.S. more than $800 billion.
Still, Panetta said earlier this week, it "has not been in vain."
Panetta and several other U.S. diplomatic, military and defense leaders participated Thursday in a symbolic ceremony during which the flag of U.S. Forces-Iraq was officially retired, or "cased," according to Army tradition. The U.S. Forces-Iraq flag was furled - or wrapped - around a flagpole and covered in camouflage. It will be brought back to the United States.
"You will leave with great pride - lasting pride," Panetta told the troops. "Secure in knowing that your sacrifice has helped the Iraqi people to begin a new chapter in history."
During a stop in Afghanistan this week, Panetta described the mission as "making that country sovereign and independent and able to govern and secure itself."
That, he said, is "a tribute to everybody - everybody who fought in that war, everybody who spilled blood in that war, everybody who was dedicated to making sure we could achieve that mission."
Iraqi citizens offered a more pessimistic assessment. "The Americans are leaving behind them a destroyed country," said Mariam Khazim of Sadr City. "The Americans did not leave modern schools or big factories behind them. Instead, they left thousands of widows and orphans."
The Iraq Body Count website says more than 100,000 Iraqis have been killed since the U.S. invasion in 2003.
A member of the political coalition loyal to anti-American cleric Muqtada al-Sadr saw another message in the U.S. withdrawal. "The American ceremony represents the failure of the U.S. occupation of Iraq due to the great resistance of the Iraqi people," said Sadrist lawmaker Amir al-Kinani.
Panetta echoed President Barack Obama's promise that the U.S. plans to keep a robust diplomatic presence in Iraq, foster a deep and lasting relationship with the nation and maintain a strong military force in the region.
As of Thursday, there were two U.S. bases and about 4,000 U.S. troops in Iraq - a dramatic drop from the roughly 500 military installations and as many as 170,000 troops during the surge ordered by President George W. Bush in 2007, when violence and raging sectarianism gripped the country. All U.S. troops are slated to be out of Iraq by the end of the year, but officials are likely to meet that goal a bit before then.
The total U.S. departure is a bit earlier than initially planned, and military leaders worry that it is a bit premature for the still maturing Iraqi security forces, who face continuing struggles to develop the logistics, air operations, surveillance and intelligence sharing capabilities they will need in what has long been a difficult neighborhood.
U.S. officials were unable to reach an agreement with the Iraqis on legal issues and troop immunity that would have allowed a small training and counterterrorism force to remain. U.S. defense officials said they expect there will be no movement on that issue until sometime next year.
Still, despite Obama's earlier contention that all American troops would be home for Christmas, at least 4,000 forces will remain in Kuwait for some months. The troops will be able to help finalize the move out of Iraq, but could also be used as a quick reaction force if needed.
Obama met in Washington with Iraqi Prime Minister Nouri al-Maliki earlier this week, vowing to remain committed to Iraq as the two countries struggle to define their new relationship. Ending the war was an early goal of the Obama administration, and Thursday's ceremony will allow the president to fulfill a crucial campaign promise during a politically opportune time. The 2012 presidential race is roiling and Republicans are in a ferocious battle to determine who will face off against Obama in the election.
Panetta acknowledged the difficulties for Iraq in the coming years, as the country tries to find its footing.
"They're going face challenges in the future," Panetta said Wednesday during a visit with troops in Afghanistan. "They'll face challenges from terrorism, they'll face challenges from those that would want to divide their country. They'll face challenges from just the test of democracy, a new democracy and trying to make it work. But the fact is, we have given them the opportunity to be able to succeed."
The ceremony at Baghdad International Airport also featured remarks from Army Gen. Martin Dempsey, the chairman of the Joint Chiefs of Staff, and Gen. Lloyd Austin, the top U.S. commander in Iraq.
Austin is leading the massive logistical challenge of shuttering hundreds of bases and combat outposts, and methodically moving more than 50,000 U.S. troops and their equipment out of Iraq over the last year - while still conducting training, security assistance and counterterrorism battles.
The war "tested our military's strength and our ability to adapt and evolve," he said, noting the development of the new counterinsurgency doctrine.
Over the coming days, the final few thousand U.S. troops will leave Iraq in orderly caravans and tightly scheduled flights - a marked contrast to the shock and awe that rocked the country on March 20, 2003, as the U.S. invasion began.
Saddam Hussein has been ousted, the reports of weapons of mass destruction largely laid to rest. And the future of a nascent democracy awaits.