Panetta said veterans of the nearly nine-year conflict can be - secure in knowing that your sacrifice has helped the Iraqi people to cast tyranny aside.
Army Gen. Martin Dempsey, the chairman of the Joint Chiefs of Staff, and Gen. Lloyd Austin, the top U.S. commander in Iraq, also spoke at the ceremony at Baghdad International Airport.
Obama's predecessor George W Bush ordered the invasion of Iraq in 2003, arguing its then leader Saddam Hussein was endangering the world with weapons of mass destruction programs.
Saddam was toppled and later executed, but such arms were never found.
After nearly nine years, 4,500 American dead, 32,000 wounded and more than $800 billion, U.S. officials formally shut down the war in Iraq — a conflict that Defense Secretary Leon Panetta said was worth the price in blood and money, as it set Iraq on a path to democracy.