Baghdad: US forces formally ended their nine-year war in Iraq on Thursday with a low key flag ceremony in Baghdad, while to the north flickering violence highlighted ethnic and sectarian strains threatening the country in years ahead.
"After a lot of blood spilled by Iraqis and Americans, the mission of an Iraq that could govern and secure itself has become real," Defense Secretary Leon Panetta said at the ceremony at Baghdad's still heavily-fortified airport.
Almost 4,500 US soldiers and tens of thousands of Iraqis lost their lives in the war that began with a "Shock and Awe" campaign of missiles pounding Baghdad and descended into sectarian strife and a surge in US troop numbers.
US soldiers lowered the flag of American forces in Iraq and slipped it into a camouflage-coloured sleeve in a brief outdoor ceremony, symbolically ending the most unpopular US military venture since the Vietnam War of the 1960s and 70s.
The remaining 4,000 American troops will leave by the end of the year.
Toppled Iraqi leader Saddam Hussein is dead, executed in 2006 and the worst sectarian violence has, at least for now, passed. But Iraq still struggles with insurgents, a fragile power-sharing government and an oil-reliant economy plagued by power shortages and corruption.
"Iraq will be tested in the days ahead, by terrorism, by those who would seek to divide, by economic and social issues," Panetta told the rows of assembled US soldiers and embassy officials at the ceremony. "Challenges remain, but the United State s will be there to stand by the Iraqi people."
In Falluja, the former heartland of an al Qaeda insurgency and scene of some of the worst fighting in the war, several thousand Iraqis celebrated the withdrawal on Wednesday, some burning US flags and waving pictures of dead relatives.
Around 2,500 mainly Shi'ite muslim residents of the northern territory of Diyala protested on Thursday in front of the provincial council building for a second day against a move to declare autonomy from the mainly Sunni Salahuddin province.
Police used batons and water cannon to disperse demonstrators who tried to storm the council headquarters, witnesses said. Some protesters climbed to the roof of the building and raised green and black Shi'ite flags.
Some parts of Diyala are disputed territories between the minority Kurds in the north and Arab Shi'ite-led government in Baghdad. The long-standing dispute over land, oil and power is considered a potential flashpoint for future conflict in Iraq after American troops depart.
Iraq's neighbours will watch how Baghdad tackles its sectarian and ethnic division without the US military. Events there could be influenced by conflict in neighbouring Syria that has taken on a sectarian hue in recent weeks.
US President Barack Obama, who made an election promise to bring troops home, told Iraqi Prime Minister Nuri al-Maliki that Washington will remain a loyal partner after the last troops roll across the Kuwaiti border.
Iraq's Shi'ite leadership presents the withdrawal as a new start for the country's sovereignty, but many Iraqis question which direction the nation will take without US troops.
"I am happy they are leaving. This is my country and they should leave," said Samer Saad, a soccer coach. "But I am worried because we need to be safe. We are worried because all the militias will start to come back."
Some like Saad fear more sectarian strife or an al Qaeda return to the cities. A squabble between Kurds in their northern semi-autonomous enclave and the Iraqi Arab central government over disputed territories and oil is another flashpoint.
Violence has ebbed since the bloodier days of sectarian slaughter when suicide bombers and hit squads claimed hundreds of victims a day at times as the country descended into tit-for-tat killings between the Sunni and Shi'ite communities.
In 2006 alone, 17,800 Iraqi military and civilians were killed in violence.
Iraqi security forces are generally seen as capable of containing the remaining Sunni Islamist insurgency and the rival Shi'ite militias that US officials say are backed by Iran.
But attacks now target local government offices and security forces in an attempt show the authorities are not in control.
Saddam's fall opened the way for the Shi'ite majority community to take positions of power after decades of oppression under his Sunni-run Baath party.
Even the power-sharing in Maliki's Shi'ite-led government is hamstrung, with coalition parties split along sectarian lines, squabbling over laws and government posts.
Sunnis fear they will be marginalised or even face creeping Shi'ite-led authoritarian rule under Maliki. A recent crackdown on former members of the Baath party has fueled those fears.
Iraq's Shi'ite leadership frets the crisis in neighbouring Syria could eventually bring a hardline Sunni leadership to power in Damascus, worsening Iraq's own sectarian tensions.
US troops were supposed to stay on as part of a deal to train the Iraqi armed forces but talks over immunity from prosecution for American soldiers fell apart.
Memories of US abuses, arrests and killings still haunt many Iraqis and the question of legal protection from prosecution looked too sensitive to push through parliament.
At the height of the war, 170,000 American soldiers occupied more than 500 bases across the country.
Only around 150 US soldiers will remain after December 31 attached to the huge US Embassy near the Tigris River. Civilian contractors will take on the task of training Iraqi forces on US military hardware.
Every day trucks with troops trundle in convoys across the Kuwaiti border.
"Was it worth it? I am sure it was. When we first came in here, the Iraqi people seemed like they were happy to see us," said Sgt 1st Class Lon Bennish, packing up recently at a US base and finishing the last of three deployments in Iraq.
"I hope we are leaving behind a country that says 'Hey, we are better off now than we were before."