Six years after the invasion of Iraq, British troops yesterday formally ended their combat mission, the UK's most controversial military operation since the Suez crisis more than 50 years ago, when they handed over their airport base to a US brigade.

"The role of British ground forces is finished," a defence official said, having completed their mission of mentoring and training two Iraqi army divisions. Yesterday's ceremonies were in many ways symbolic. British forces had been winding down their presence in Basra for many weeks and had already handed over responsibility for Basra's security to the Iraqis at the start of the year.

It was significant that UK forces handed over their base not to the Iraqis but the Americans. US forces will remain in Basra protecting the important supply route from Kuwait, and helping the Iraqi army and police force.

A memorial service was held in Basra for the 179 British personnel who have died since the invasion, attended by John Hutton, the defence secretary. He said: "I think when the history is written of this campaign, they will say of the British military 'we did a superb job'."

All the remaining 4,000 or so UK troops in Basra will have left the base by 31 May, say defence officials, but around 400 will remain training Iraqi forces, mainly the navy, at Umm Qasr, Basra's port.

Air Chief Marshal Sir Jock Stirrup, chief of the defence staff, said British forces had made an "outstanding contribution to the transition of Iraq from dictatorship and regional pariah to burgeoning democracy and constructive partner".

General Sir Richard Dannatt, the head of the army, said "the road to success has been long and, at times, painful ... As in any operation of this nature and complexity, things did not always develop as we might have expected. It is therefore critical that we, as an army and within defence as a whole, learn from our experiences in Iraq and implement those lessons for current and future operations."

David Cameron said that now the departure of British forces was imminent, it was time the government announced what he called "a proper Franks-style inquiry" into the events leading up to the invasion of Iraq. The Franks inquiry into the Argentinian invasion of the Falklands was made up of privy counsellors and met in private.

Gordon Brown and Nouri al-Maliki, Iraq's prime minister, marked the end of military operations by signing an agreement on economic and technical co-operation. Brown said after talks at No 10 that Britain wanted to get involved in protecting oil supplies from Iraq, which produces nearly 2m barrels of oil a day.

Maliki later joined senior Iraqi officials and business leaders at a London investment conference attended by representatives from more than 200 companies, from Shell to Rolls-Royce and Barclays Capital. "There are people in Iraq who want the government to fail but our armed forces are ready to face these challenges," Maliki said, arguing that security and economic progress went hand in hand. "We need, more than at any other time in the past, a vibrant private sector."

He said that his government was working to amend Iraqi law to allow foreign investors to own land. Currently, foreign investors are permitted to lease property for up to 50 years. Iraq has been badly hit in recent months by weak oil prices, and falling production and exports, and the government has had to cut its 2009 budget several times.

Douglas Alexander, the international development secretary, said: "As the military-led phase of our engagement in Iraq ends we look forward to a future based on close economic and cultural ties."