Major General Andy Salmon, head of coalition forces in Basra in southern Iraq, acknowledged there had been "ups and downs" since the 2003 invasion and paid tribute to the 179 British personnel who lost their lives during the conflict.
But he insisted that UK forces were leaving Basra a much safer and more optimistic place compared with the darkest days of the insurgency.
In an interview ahead of his imminent departure from Iraq, he said: "I can put my hand on my heart and say we've finished this right.
"I know that it was a very difficult start - we all know that. We know that actually we went through some difficult times. So did the US Army, we all went through difficult times.
"We stayed the course and we endured, and we partnered with everybody, and seized our opportunities and adapted along the way."
British combat operations in Iraq will end on May 31 and nearly all of the UK's remaining 4,100 troops in the country will be withdrawn by July 31.
Maj Gen Salmon, of the Royal Marines, will leave Iraq ahead of this after standing down as general officer commanding the coalition's Multi-National Division (South-East) and handing control of Basra Province to US forces.
He listed a series of achievements by the British Armed Forces in Iraq, from deposing Saddam Hussein and training the new Iraqi Army to helping to deliver successful provincial elections in January and attracting investors to Basra.