The American war in Iraq came to an unspectacular end Thursday at a simple ceremony held on the edge of Baghdad’s international airport, not far from the highway along which U.S. troops first fought their way into the capital more than eight years ago.

There were speeches paying tribute to the fallen, promises that the United States would not abandon Iraq, vague declarations of “success” and warnings of challenges ahead. A brass band played, and the flag that had flown over the headquarters of the U.S. mission here was lowered for the last time and folded away.

And that was it. No pronouncements of victory, no cheers or jubilation — only a profound sense that the war’s real reckoning is yet to come, even as the American part in it draws to a close.

No senior Iraqi government officials showed up for the event, though the name tags attached to two chairs in the front row indicated American hopes that they might. One was labeled for Prime Minister Nouri al-Maliki, the other for President Jalal Talabani.

The only prominent Iraqis to attend were a former defense minister and three generals who have worked closely alongside U.S. forces and have often expressed hope that they would remain.

It was a reminder that for all the declarations of progress, the troops are leaving primarily because most Iraqis wanted them to go, despite the significant lingering concerns about the capabilities of the Iraqi security forces and the country’s still-precarious political balance.

Gen. Lloyd J. Austin III, the sixth and last general to command American forces in Iraq, alluded to those uncertainties when he spoke of the “opportunities” U.S. troops had created for Iraqis to live freely and prosper, without sounding at all sure that they will.

But he also warned that militant groups may yet disrupt the gains the Iraqi security forces have made in recent years, at a time when the turmoil of the Arab revolts threatens to reignite Iraq’s sectarian tensions and fuel regional rivalries.

“There’s no doubt this is a challenging time for Iraq and its neighbors,” Austin told a small group of U.S. troops and dignitaries gather within an encirclement of fortified concrete. “But Iraq has the opportunity to assume a position of leadership if it follows the right path.’’

For many Iraqis, too, it was an ambivalent conclusion to the upheaval of the past eight years, which has transformed their country beyond recognition without, in the eyes of many, significantly improving their lives. More than 100,000 Iraqis died in the bloodshed that followed the invasion, and though violence is greatly reduced, bombings and assassinations remain a daily occurrence.

On the streets of Baghdad, residents overwhelmingly said that they were glad the U.S. troops were going home, but some also seemed nervous that the departure of the Americans could rekindle latent power struggles and perhaps intensify the violence.

“Sooner or later, the American flag had to be taken down because it is unacceptable to live in the shadow of their flag,” said businessman Qais al-Lami, 39. “So I’m happy they’re leaving because they are occupiers.

“But also I’m not happy, because now all the political parties and the militias will become more aggressive in asserting their power, and the security situation could get worse.”

In the Sunni town of Fallujah, scene of the biggest pitched battle of the war, between Marines and insurgents in 2004, relief at the U.S. departure was tempered by concerns that the Shiite-led government will crack down on members of the Sunni minority.

“What’s the point of lighting a candle at the beginning of a tunnel when you know you will be walking in darkness?” asked Bashar al-Nadeq, 32, explaining why he won’t celebrate the departure of the troops, even as he rejoices that they are going.

The persistent dangers were underscored by the strict security measures surrounding the U.S. ceremony and the small scale of the farewell pageantry. Visitors’ badges carried numbers identifying which bunkers they should access in the event of a rocket attack. The date was kept secret for months to prevent insurgents from targeting the site.

U.S. commanders had openly urged Iraqi leaders to extend the American military’s presence beyond the agreed Dec. 31 deadline, so that they could continue to train the Iraqi security forces, build the country’s almost-nonexistent conventional defenses and allow more time for the wobbly political consensus forged after elections last year to solidify.

But in a rare display of consensus, Iraq’s usually squabbling factions united to insist that U.S. troops could stay only if they were subject to Iraqi law, a condition that the American military had made clear from the outset would not be acceptable.

Defense Secretary Leon E. Panetta, the most senior U.S. official at the ceremony, told those who attended that America’s role in Iraq is by no means over. He referred to a $6 billion effort being undertaken by the State Department to sustain U.S. influence now that the military role has ended.

“Challenges remain, but the U.S. will stand by the Iraqi people as they navigate those challenges to build a stronger and more prosperous nation,” he told the gathering.

A newly established Office of Security Cooperation-Iraq (OSCI), under the auspices of the U.S. Embassy, will retain 157 military personnel to continue to help train the Iraqi security forces. The State Department will also employ thousands of private security contractors to assume many of the functions that had been performed by the military and cannot be dispensed with given the dangerous conditions.

The air terminal where the ceremony was held is a former military facility that henceforth will be operated by the embassy. The State Department will also run a fleet of 80 MRAP (mine-resistant, ambush-protected) armored fighting vehicles to transport diplomats, using civilians who have been taught by the military to drive them.

The ceremony effectively ends the war two weeks earlier than was necessary under the terms of the security agreement signed by the U.S. and Iraqi governments in 2008, which stipulated that the troops must be gone by Dec. 31.

But U.S. commanders decided that there was no need to keep soldiers in Iraq through the Christmas holidays once the talks on extending the American troop presence beyond the deadline failed. Within days, all of the 4,500 troops who remain — most of them only to guard the ceremony and the exit routes out of the country — will be gone.