Baghdad - Agencies
While US troops cheered Obama's speech, Fallujah residents burnt US flags
In a symbolic move, US forces will lower their flag in Iraq on Thursday, in a formal ceremony ahead of their withdrawal from the country nearly nine years after the controversial invasion
to topple Saddam Hussein.
The ceremony marking the closure of the US military's headquarters in Iraq comes after US President Barack Obama hailed the "extraordinary achievement" of the war in a speech to welcome home some of the troops.
There are a little more than 4,000 US soldiers in Iraq, but they will depart in the coming days, at which point almost no more American troops will remain in a country where there were once nearly 170,000 personnel on more than 500 bases.
Majority of the remaining soldiers have now left the war-torn country, with security in the hands of the Iraqi authorities.
US President Barack Obama, who pledged to bring troops home as part of his 2008 election campaign, said the US left behind a "sovereign, stable and self-reliant Iraq".
Some 4,500 US soldiers and more than 100,000 Iraqis have died in the war.
It has cost the US some $1tr.
US Republicans have criticised the pullout citing concerns over Iraq's stability, but most US citizens support the move.
The withdrawal will end a war that left tens of thousands of Iraqis and nearly 4,500 American soldiers dead, many more wounded, and 1.75 million Iraqis displaced, after the 2003 US-led invasion unleashed brutal sectarian fighting.
In an aircraft hangar at Fort Bragg in North Carolina, Obama was cheered by soldiers as he honoured nearly nine years of "bleeding and building."
"Tomorrow (Thursday), the colors of United States Forces - Iraq, the colours you fought under, will be formally cased in a ceremony in Baghdad," he said.
"Everything that American troops have done in Iraq, all the fighting and dying, bleeding and building, training and partnering, has led us to this moment of success," he said.
"The war in Iraq will soon belong to history, and your service belongs to the ages."
He said the war had been "a source of great controversy" but that they had helped to build "a sovereign, stable and self-reliant Iraq, with a representative government that was elected by its people".
In Afghanistan, US Defence Secretary Leon Panetta said he would be heading to Iraq to attend the ceremony to "encase the flag and mark the end of the combat effort that we've made as a country."
"Our mission there was to establish an Iraq that would be sovereign and independent, that would be able to govern and secure itself. And I think we've done a great job there in trying to achieve that mission," he told US soldiers.
"It doesn't mean they're not gonna face challenges in the future. They're gonna face terrorism, they're gonna face challenges from those that will want to divide their country, they'll face challenges from just the test of ... a new democracy and trying to make it work," said Panetta.
But "the fact is that we've given them the opportunity to be able to succeed."
Some 1.5 million Americans have served in Iraq since the US invasion in 2003. In addition to those who died, nearly 30,000 have been wounded.
Troop numbers peaked at around 170,000 during the height of the so-called surge strategy in 2007, but as of this week only about 5,500 remained. Many of them have already left for bases in Kuwait prior to flying home.
The last combat troops left Iraq in August last year. A small contingent of some 200 soldiers will remain in Iraq as advisers, while some 15,000 US personnel are now based at the US embassy in Baghdad - by far the world's largest.
Some Iraqis have said they fear the consequences of being left to manage their own security.
Baghdad trader Malik Abed said he was grateful to the Americans for ridding Iraq of Saddam Hussein, but added: "I think now we are going to be in trouble. Maybe the terrorists will start attacking us again."
But in the city of Falluja, a former insurgent stronghold which was the scene of major US offensives in 2004, people burned US flags on Wednesday in celebration at the withdrawal.
"No-one trusted their promises, but they said when they came to Iraq they would bring security, stability and would build our country," Ahmed Aied, a grocer, told Reuters news agency.
"Now they are walking out, leaving behind killings, ruin and mess."
Concerns have also been voiced in Washington that Iraq lacks robust political structures or an ability to defend its borders.
There are also fears that Iraq could be plunged back into sectarian bloodletting, or be unduly influenced by Iran.
Fallujah, a city of about half a million people west of Baghdad, remains deeply scarred by two American military offensives in 2004, the latter of which is considered one of the fiercest for the United States since Vietnam.
Obama's predecessor George W. Bush ordered the invasion of Iraq in 2003, arguing its then leader Saddam Hussein was endangering the world with weapons of mass destruction programmes.
Saddam was toppled and later executed, but such arms were never found.
Obama made his political career by opposing the war. In late 2002, he said he was against "dumb wars" such as Iraq, and rode anti-war fervor to the White House by promising to bring troops home.
The war was launched in March 2003 with a massive "shock and awe" campaign, followed by eight-plus years in which a US-led coalition sought not only had to rebuild the Iraqi military from the ground up, but also to establish a new political system.
Iraq now has a parliament and regular elections, and is ruled by a Shiite-led government that replaced Saddam's Sunni-dominated regime.
The pullout, enshrined in a 2008 bilateral pact, is the latest stage in the changing US role in Iraq, from 2003-2004 when American officials ran the country to 2009 when the United Nations mandate ended, and last summer when Washington officially ended combat operations.
The conflict soon became hugely unpopular as claims that Saddam was hiding weapons of mass destruction and supporting Al-Qaeda militants turned out to be untrue.
It descended into sectarian conflict, costing tens of thousands of Iraqi lives.
Mr Obama announced in October that all US troops would leave Iraq by the end of 2011, a date previously agreed by Bush in 2008.