"The war in Iraq will soon belong to history, and your service belongs to the ages," he said, applauding their "extraordinary achievement."
U.S. troops are scheduled to be gone from Iraq by Dec. 31. Civilian assistance from the U.S. is expected to continue in order to assist the Iraqi government.
A majority of Americans favor ending the war in Iraq.
Republicans in the House and Senate have criticized Obama for the troop withdrawal, saying Iraq is too unstable to be left alone.
Sen. John McCain of Arizona, Obama's one-time rival for the presidency, issued a particularly harsh verdict on his handling of Iraq. "I believe that history will judge this president's leadership with the scorn and disdain it deserves," McCain said on the Senate floor.
Obama, who became president in part because of his opposition to the Iraq war, said the war faced twists and turns amid one constant: the patriotism and commitment of U.S. troops.
Obama has on several occasions addressed his reasons for ending the war, casting it as a promise kept after he ran for president as an anti-war candidate and speaking of the need to refocus U.S. attention on rebuilding the troubled economy at home.
Obama's approval rating on handling the situation in Iraq has been above 50 percent since last fall, and in a new Associated Press-GfK poll, has ticked up four points since October to 55 percent. Among independents, his approval rating tops 50 percent for the first time since this spring.
Obama said Wednesday that Iraq "is not a perfect place." But "we are leaving behind a sovereign, stable, and self-reliant Iraq, with a representative government that was elected by its people. We are building a new partnership between our nations."
The Associated Press contributed to this report.