British forces handed over military control of the Basra area to U.S. commanders Thursday to clear the way for America's main battlefield ally to exit Iraq after more than six years of war.

The U.S. flag rose over a British base outside Basra, the last main outpost for about 4,000 British forces in southern Iraq who will almost all withdraw by the end of May.

At the height of combat operations after the March 2003 invasion, Britain had 46,000 troops in Iraq. Washington still has about 130,000 troops in the country and has shifted units south ahead of the British pullout.

American troops operate alongside Iraqi soldiers who have taken over many front-line roles in the strategic Basra area, the hub of British military operations for years.

"Today marks the closing chapter of the combat mission in Iraq," British Prime Minister Gordon Brown said in London after meeting with Iraqi Prime Minister Nouri al-Maliki.

The Iraq war has been extremely unpopular in Britain, and the issue shadowed the final years of Tony Blair's premiership.

Since the 2003 U.S.-led invasion, 179 British service personnel have been killed in Iraq. The British military dedicated a memorial wall to those killed Thursday, part of the preparations for withdrawal.

"They will always be remembered for the service they have given. Our country owes them a huge debt of gratitude," Brown said.

British commanders have been gradually handing over responsibility of the oil-rich Basra region to the U.S. military since March and have been withdrawing troops from the country in phases. Nearly all of its troops are expected to be withdrawn by May 31, British military officials have said.

About 400 British troops will remain under an agreement with the Iraqi government mainly to train the Iraqi navy to defend oil platforms in the Gulf, the British Ministry of Defense has said.

The British pullout comes as violence in Iraq has dropped to its lowest levels since the start of the war. But a series of high-profile attacks in recent weeks that have killed hundreds have raised concerns about whether the Iraq military is ready to take control.

The Americans have shifted about 1,000 soldiers to replace the departing British troops to ensure a smooth transition and protect U.S. military supply lines from Kuwait to American bases throughout Iraq.

President Barack Obama has said he plans to withdraw American combat troops from Iraq by Aug. 31, 2010, leaving a contingency force of up to 50,000 to train and advise the Iraqi security forces. The remainder of American troops are required under a U.S.-Iraqi security pact to leave by the end of 2011.

Obama said the recent attacks are a concern but the U.S. must keep pressure on the Iraqis to make the necessary political progress to help improve security.

On Thursday, the Iraqis took control of security of the Khor al-Amaya oil terminal.

The Iraqi navy's takeover of the oil terminal — a platform that was built in 1959 and is fed by only one 42-inch pipeline — is a small but important step, officials have said.

U.S. and British forces will continue to help protect the newer al-Basra oil terminal, which has two 48-inch pipelines that produce 80 percent of Iraq's crude exports.