"It was a disgrace that should have never happened," he added.
Earlier, having reflected on the scaling down of conflict in Iraq and Afghanistan under his watch, the president vowed he would not take the U.S. into another war if he can possibly avoid it.
The comments appeared in part to be a swipe not only at his predecessor over the discredited justifications for the rush to invade Iraq but a response to increasingly belligerent Republican opponents pressing for a more strident attitude toward Iran and Syria.
"As commander-in-chief I can tell you that sending troops into harm's way is the most wrenching decision that I have to make. I can promise that I will never do so unless it's absolutely necessary. And that when we do, we must give our troops a clear mission and the full support of a grateful nation," he said.
President Obama said that, with the war in Iraq finally over, it was fitting to pay tribute to the sacrifices made in that conflict.
"Especially for those who have lost a loved one, this chapter will remain open long after the guns have fallen silent," he said.
The president recalled that the first U.S. military casualties of the Iraq war came on the first day of the invasion when four Marines died in a helicopter crash on the border. He said that eight years, seven months and 25 days later, David Hickman became the last American casualty when his vehicle struck a roadside bomb in Baghdad.
"To the families here today, I repeat what I said to the Hickmans: I cannot begin to fully understand your loss. As a father, I cannot begin to imagine what it's like to hear that knock on the door and learn that your worse fears have come true," he said.
Nearly 4,500 U.S. soldiers died in Iraq. The Vietnam Veterans Memorial carries the names of 58,282 U.S. soldiers killed in the conflict.
Intellpuke: You can read this article by Guardian Washington, D.C., correspondent Chris McGreal and New York correspondent Matt Williams in context here: www.guardian.co.uk/world/2012/may/28/barack-obama-tribute-memorial-day