Eight years and three months after "liberating Iraq", a time of unrelenting savage strife in which tens of thousands died and a society was torn apart, the United States has finally ended its war in Iraq.

Eight years and three months after "liberating Iraq", a time of unrelenting savage strife in which tens of thousands died and a society was torn apart, the United States has finally ended its war in Iraq.

After the US forces' colours were lowered and the 'Last Post' was played, Defence Secretary Leon Panetta, right, told troops: "You will leave with great pride, lasting pride, secure in knowing that your sacrifice has helped the Iraqi people to cast tyranny aside and to offer hope for prosperity and peace to this country's future generations."

The ceremony, just 48 minutes long to limit the scope of any possible attack, was held behind high, fortified walls in a concrete courtyard at the airport in Baghdad.

"We spilled a lot blood here," Mr Panetta acknowledged.

But, he insisted: "It has been to achieve a mission making the country sovereign and independent and able to govern and secure itself." Not far from where the speeches were taking place lay grim evidence which refuted the claims that the Americans were leaving behind a land of stability and prosperity. More than 8,000 people are living in squalor in a field of mud and foetid water, with huts made with salvaged pieces of wood.

The residents of Al-Rahlat camp are among 1.3 million refugees in their own country; families driven out of their homes by the sectarian violence spawned by the war. Another 1.6 million fled Iraq for neighbouring states, mainly Jordan and Syria. Those in Syria, with its escalating violence, are now having to seek another refuge.

There is a third group who are particularly vulnerable -- around 70,000 people who worked for the US military. They were promised the offer of refuge in the US, but little has been done fulfil the pledge. Barack Obama, while campaigning for the White House four years ago, berated the Bush administration over the issue, saying: "The Iraqis who stood with us are being targeted for assassination, yet our doors are shut. That is not how we treat our friends."

In 2008 Congress passed a bill for 'special immigration visas' to be issued for 25,000, but only 3,000 have been processed.

Around 450,000 of the IDPs (internally displaced persons) are living in the worst conditions, crammed into 380 street settlements scattered around the country. They have little or no access to clean water, sanitation or medical care. Many of these people, deemed to be illegally squatting, cannot get the documents necessary to register for welfare relief or take up jobs, or enrol their sons and daughters in schools. The tension and claustrophobia of such an existence has led to psychological problems. Domestic violence is rife.

Hakim al-Ibrahimi, a 47-year-old unemployed bricklayer, has been stuck at Al-Rahlat camp, in the Shia enclave of Sadr City, for the last two years with his wife and four children. "I was staying with my brother and his family. But there were 11 of us in a flat with two bedrooms, it became impossible," he said.

"Officials tell us to go back to our home. But what home? We used to live in Adhamiya [a mainly Sunni area] and we had to escape otherwise we would have been killed. That was four years ago and I know someone else is living in my house with his family. Life here is really bad, but if we go back to Adhamiya we won't be safe."

The turbulence of Iraq's recent history had taken its toll on Amal's family (not her real name). Her husband was killed in the war with Iran and a son Akram was executed by Saddam Hussein's regime after joining the rebel opposition. A second son, Mazruq, died in a sectarian attack.

Amal lives at a camp with her daughter and three grandchildren. She has not received compensation under a scheme set up by the Iraqi government for civilian victims of the war.

The International Rescue Committee (IRC), which provides humanitarian assistance, has taken up the case of Amal and dozens of others. The IRC said: "As the US government withdraws its troops, it leaves behind a major crisis in the region. The US has a responsibility to aid Iraqis uprooted by war it started and to protect the most vulnerable."

Laura Jacoby, with the IRC in Baghdad, said: "The main worry is that with the US forces leaving, international donors may go as well. The Iraqi government is organising assistance, but we face a very serious problem inside Iraq and in Syria and Jordan as well."