BAGHDAD, Iraq (CNN) -- The largest and longest-serving unit of U.S. soldiers in Iraq is heading home after a 15-month deployment.

The soldiers from the 1st Armored Division, based in Germany, and the 2nd Armored Cavalry Regiment, based at Fort Polk, Louisiana, "cased their colors," or folded their military flags ahead of their departure from Iraq during a formal military ceremony on Sunday at Baghdad International Airport.

The ceremony took place on the Fourth of July, the day Americans celebrate their nation's independence from British rule, and marked the end of duty in Iraq for some 20,000 U.S. soldiers whose service was extended for three months to help defeat a militia uprising in the south.

After the ceremony, the 1st AD commander, Maj. Gen. Martin Dempsey said it was hard to sum up 15 months of his experience in Iraq.

"I think that the real emotion is one of great pride," he told CNN's Jane Arraf.

Dempsey said while his experience has been a series of "three steps forward and one step back," ultimately the Iraqi people have been given a great opportunity.

"Freedom and democracy are kind of a messy form of government ... and I think that it'll take them awhile to get their feet under them and their legs under them to figure out what to do with it, but what an opportunity."

The 1st Armored Division provided security in the Iraqi capital of Baghdad and the 2nd Armored Cavalry Regiment was responsible for patrolling the area east of Baghdad.

Both units were scheduled to be relieved by the 1st Cavalry Division when U.S. Defense Secretary Donald Rumsfeld announced on April 15 that their tour of duty would be extended, citing an increase of attacks by Iraqi insurgents.

After newly elected Spanish Prime Minister Jose Luis Rodriguez Zapatero honored a campaign promise to pull his troops from Iraq, the 1st AD redeployed to the southern Shiite holy city of Najaf.

Najaf was where the Spanish troops were based -- in the midst of an uprising by the Medhi Army, a militia loyal to radical cleric Moqtada al-Sadr.