Foreign Secretary Jack Straw has warned of "more dark moments" in Iraq but said UK troops would stay to help its elected leaders build a stable nation.
The United Nations needs reform to survive, says Jack Straw
In his speech at Labour's annual conference in Brighton, Mr Straw vowed to put "the responsibility to protect" at the heart of British foreign policy.
He said such a policy would have saved many lives in Rwanda and Srebrenica.
But it was the passage of his speech on Iraq which drew an adverse reaction from some delegates.
He was heckled as he spoke and two men, one an 82-year-old, were ejected.
Police used the Terrorism Act to stop the elderly delegate from returning. Labour said later it would apologise for the way the protester was ejected from the hall.
Mr Straw said: "We are in Iraq for one reason only - to help the elected Iraqi government build a secure and stable nation and will only remain there with their consent."
He warned that the "challenges that still lie ahead" in Iraq should not be underestimated.
But he added: "Nation building, from a violent past, has never been easy."
Security staff tackle hecklers during Mr Straw's speech
He compared Iraq to Germany after the Second World War, where it had taken four years before elections were held.
As Mr Straw spoke, 82-year-old Walter Wolfgang shouted "nonsense" and was ejected from the hall by conference security.
And a younger man who protested about his treatment was himself taken out.
Mr Straw also used his speech to say Britain should be at the vanguard of a new recognition "that sovereign states and the nations of the world ... have a collective responsibility to protect all citizens from genocide, ethnic cleansing and crimes against humanity".
"If this new responsibility had been in place a decade ago, thousands in Srebrenica and Rwanda would have been saved," he is saying.
"My pledge to you is to ensure that the fine words on the responsibility to protect are translated into collective action."
Mr Straw says this policy became clear to him when Srebrenica marked the 10th anniversary of the massacre of 7,000 Bosnian Muslims in Srebrenica.
'No easy task'
The town was overrun by Serb forces in July 1995. A grave with the remains of 700 Muslim men and boys was uncovered two years ago.
"Three months ago I sat in a field laid out with 700 coffins as the town of Srebrenica marked the anniversary of that massacre," Mr Straw is telling delegates.
"Those 700 were denied a decent burial for 10 years. I reflected that day on how the whole world had failed to meet its responsibilities to protect those people."
Earlier Mr Straw ruled out military action in Iran, telling BBC Radio 4's Today programme it was "inconceivable".