A member of U.S. security personnel pulls her luggage while waiting to depart from Iraq,
A member of U.S. security personnel pulls her luggage while waiting to depart from Iraq Mohammed Ameen / Reuters

The U.S. military flag in Baghdad was formally furled and cased Wednesday, marking the historic end of the American campaign in Iraq almost nine years after the invasion.

Defense Secretary Leon Panetta, Chairman of the Joint Chiefs of Staff Gen. Martin Dempsey and top U.S. commander in Iraq Gen. Lloyd Austin spoke at Baghdad International Airport during a military ceremony.

U.S. Ambassador to Iraq James Franklin Jeffrey opened the ceremony, described as simple and low-key by different reports. He said the United States is looking forward to a Iraq that is "safe, secure and self-reliant".

Panetta paid tribute to the troops who fought in Iraq. "You came to this land between the rivers, again, again and again," he said. "You did now know that you would return to your loved ones. You will leave with great pride, secure in knowing that your sacrifice has helped the Iraqi people begin a new sacrifice free from tyranny."

Then he recalled the campaign's high cost on human lives. "To be frank, the cost was high for the U.S. and also for Iraqi people," he said. "But those lives were not lost in vain. They give birth to independent, free and sovereign Iraq, yielding to a new era of opportunity."

He added that he will not forget the sacrifice of nearly 4,500 U.S. soldiers killed in the country.

"Iraq will be tested in days ahead by terrorism, those who seek to divide the country, economic and social issues, demands for democracy and so on," he said. "Challenges remain, but U.S. will be there with a strong diplomatic presence to stand by the Iraqi people to build a stronger nation."

Panetta called Iraq a "committed friend" of the U.S.

"Iraqi people now look closer to realising the fundamental dream of humanity, to build a better life," he said. "Children will have a better future: this is the reward of this historic day. This is not the end. This is the truly beginning."

Austin talked about progress in Iraq that has given people opportunities they have never seen.

"We have created hope," he said. "We have witnessed remarkable progresses together and will continue to improve in the course of national election in forming the government."

The flag of the command was lowered and encased during the ceremony. That marked the official end of the mission that began with the United States-led invasion of Iraq in March 2003, aimed at toppling Saddam Hussein.

Saddam's regime fell in a matter of weeks. He was captured in December 2003 after months in hiding, then hanged after a trial. All U.S. troops will be out of Iraq by the end of this month.

President Barack Obama, speaking at Fort Bragg in North Carolina, welcomed troops that were returning home.

"As your commander in chief, and on behalf of a grateful nation, I'm proud to finally say these two words, and I know your families agree -- welcome home. Welcome home," he said Wednesday.