Mr Brown said the UK's partnership with Iraq would continue
Gordon Brown has rejected calls for an early inquiry into the Iraq war, saying it would not be considered until UK troops are out of the country.
Conservative leader David Cameron and Lib Dem leader Nick Clegg both want an inquiry now that the exit date for British troops of 31 July has been set.
The exchanges came as the prime minister told MPs a "rapid withdrawal" of 4,100 UK troops would begin in June.
Just 400 would remain by the end of July to help with training, he said.
The prime minister paid tribute to the "heroism" of UK troops, saying they had endured great "hardship and sacrifice".
He also confirmed that the memorial wall to British troops killed in Iraq would be brought home from Basra to the UK.
Tory leader David Cameron "welcomed" the timetable for withdrawal but called again for an inquiry into the war.
Mr Cameron said a full-scale inquiry into the origins and conduct of the Iraq war was vital so "we can learn from the mistakes made" there.
Lib Dem leader Nick Clegg called on ministers to apologise for taking the UK into what he said was an "illegal war".
During a meeting with Iraqi PM Nouri Maliki on Wednesday, Mr Brown confirmed that military operations will end by 31 May and the bulk of the UK's remaining personnel will leave within two months.
The prime minister said this was possible because of the success of the UK's mission in improving security, training Iraqi troops and police, reducing violence around Basra and helping reconstruction - tasks which would be completed by the end of May.
Several hundred troops will remain in a training capacity, working with the Iraqi navy and helping to protect Iraq's oil facilities.
Confirmation that the UK's six-year presence in Iraq is to end intensified calls for an independent inquiry into the background to the invasion, how it was conducted and how military operations have been carried out since then.
Mr Cameron called for a "robust, independent" inquiry into the war similar to that conducted after the Falklands conflict, with a wide remit and the power to question ministers.
He said the government "owed" it to the those who had died in Iraq to agree to this and to ensure the mistakes made in Iraq were not repeated in Afghanistan.
The UK is expected to come under pressure to send more troops to Afghanistan next year as fighting between the existing Nato force there and the Taleban intensifies.
For the Lib Dems, Mr Clegg said ministers should be "ashamed" of taking the UK to war on a false premise in 2003 and the Conservatives should be "ashamed" of supporting the government.
"Isn't it time the government and the opposition held up their hands and said sorry to the British people for Iraq?" he said.
He called for an inquiry to be held in public so people could get the fullest account of decisions taken in the run-up to the war.
"The government must not end this war as it started it, in secret, unaccountable and behind closed doors."
The SNP and Plaid Cymru also called for an inquiry to be set up as soon as possible.
"Those responsible have never answered the most fundamental questions about why we were led into this war," said Angus Robertson, the SNP's defence spokesman.
Mr Brown has said the country should be "proud" of the role that British troops have played in Iraq.
He said Iraq had seen "dark days" but significant progress had been made and, even after the troop withdrawal, the UK would maintain a strong defence and trade relationship with Iraq.
"People can be proud that Iraq is a far better place than it was five years ago."
Before leaving Iraq on Wednesday, Mr Brown laid a wreath in memory of the 178 British servicemen and women who have been killed there since 2003.
Mr Brown also announced the £150m purchase of more than 100 Warthog armoured personnel carriers for troops in Afghanistan.
The prime minister said: "We have always tried to respond to the requests, either for helicopters, or for better night equipment or for vehicles, and we will continue to do so."
Defence equipment minister Quentin Davies said the vehicles would provide improved protection to British forces.