At Al-Faw Palace on Baghdad's outskirts, the footsteps of a dwindling number of American officers and soldiers echo through nearly deserted marble hallways.

Four-star generals, one after another, have fought a dramatically shifting war from here. But after eight years, more than 4,400 US deaths, and billions of dollars spent since its military toppled Saddam Hussein, the United States appears to be fighting to finish what it started.

As the deadline for US withdrawal looms, Iraq's readiness to ensure security, stability, and democratic freedoms remains uncertain. But some segments of Iraqi society oppose the US maintaining a presence here – even a diplomatic one.

"On the international level there's a great deal we have to offer," says a senior US embassy official. "I think the prime minister understands and appreciates that. I think much of the political leadership does. I'm not sure the Iraqi public does."

On paper, the future of the US military in Iraq is clear-cut. US and Iraqi officials say there are no plans and no negotiations to extend the troop presence here past the agreed Dec. 31 deadline – a major political priority in both Washington and Baghdad. But faced with that rapidly approaching date in a newly volatile Middle East, the US, at least, seems to be having second thoughts.

"How many of you know when you're going to be going home?" Gen. Martin Dempsey, the US Army's top general, asked a group of soldiers during a recent visit to Baghdad. Only a handful raised their hands.

Dempsey, who arrived in Baghdad as commander of the 1st Armored Division in 2003, was told then that US forces would be in Iraq for only six months.

"When we were deployed we weren't sure how long we'd be here. We weren't really sure what we'd be asked to do," he told the soldiers. "I'd suggest that's where you are right now. You're giving the nation options."

US, Maliki potentially open to extension

Adm. Mike Mullen, chairman of the Joint Chiefs of Staff, has expressed an openness to keeping a US military presence in Iraq past December.

"Should the Iraqi government desire to discuss the potential for some US troops to stay, I am certain my government will welcome that dialogue," he said at a late April news conference in Baghdad. He warned, however, that that request had to be made within the next few weeks.

Prime Minister Nouri al-Maliki said on May 11 that he was open to an extended US stay if there was enough backing from Iraqis, but was vague about how much support he would require – and from whom. He has insisted that Iraqi forces can take care of their internal security – "our agencies and our forces have become competent and capable of controlling the security situation," he said last month – but acknowledged that Iraq needs help meeting outside threats.

"We've not had the ability to really focus in earnest on providing for an external defensive capability. So the Iraqis still need to work on that," Gen. Lloyd Austin, head of United States Forces – Iraq (USF-I), told reporters recently. He said Iraqis also still lacked the ability to defend their skies and needed to develop their intelligence capability and logistics.

In addition to advanced training required on US tanks and artillery they've purchased, they also need training on how to use them together. "It's pretty complex – they're likely to have continued needs well into the future," says Maj. Gen. Jeffrey Buchanan, spokesman for USF-I.

Key concern: Peace along disputed internal borders

But the major and more politically sensitive area of concern is the US military's role in keeping tensions from erupting along the disputed boundaries between the Kurdish-controlled north and central Iraq. In those flash-point areas, US soldiers have served as a buffer between the Kurdish peshmerga forces and Iraqi government soldiers.

"Let's be clear – the reason we should stay is to keep the Iraqis from fighting each other, particularly the Kurds and the Arabs," says Peter Mansoor, a former executive officer to Gen. David Petraeus and a professor of military history at Ohio State University. "We can couch it in whatever terms we want to but ... they need us to protect them from themselves," he said in a telephone interview.

If there is no new agreement, after the end of this year the only US troops that will be allowed to be here will be about 150 marines protecting the embassy and approximately 115 military attachés within the diplomatic mission. The US military could sign bilateral agreements for joint training exercises and conduct programs to train Iraqi officers in the US, but not have troops based on Iraqi soil.

Sadr threatens to reactivate his fighters

Any troops remaining here under a new agreement would be far fewer than the current 47,000 still in the country – possibly only several thousand. But for many Iraqis, any American soldiers in the country are too many.

Hard-line Shiite cleric Moqtada al-Sadr, whose Mahdi Army mounted a major offensive against US forces early in the war, announced last month that even if US military forces withdraw, he would consider an expanded embassy grounds for reactivating his fighters.

Mr. Sadr's political bloc is crucial to Mr. Maliki's carefully constructed coalition government; if Sadrists pull out of the coalition, the government could collapse. Many in former Prime Minister Ayad Allawi's Iraqiya bloc, the major Sunni-backed faction, would likely favor some US troops remaining, but Mr. Allawi has refused to participate in Maliki's government, saying it has reneged on its promise of power sharing.

The Kurds, who benefited from US protection under Mr. Hussein, are the biggest proponent of a continued US military presence. One proposal would have Kurdish President Massoud Barzani, who mediated between Maliki and Allawi in trying to form a government, bring them together again.

Maliki has not raised the issue of a new US agreement with his cabinet, and he doesn't even have a defense minister to explain the capabilities of Iraqi security forces to parliament. The Defense and Interior Ministry posts are still vacant more than a year after the elections.

US set to expand Baghdad embassy, already biggest in the world

The US plans a large civilian presence in Iraq regardless of whether US forces stay. US Ambassador Jim Jeffrey recently told reporters that the US embassy here, already the biggest in the world, plans to double in size next year to about 16,000 people. That would include diplomatic missions outside Baghdad along with support staff and security contractors. US officials now say that number is no longer accurate but decline to put a new figure on it.

From the embassy, the State Department plans to direct a huge Iraqi police training program as well as a wide range of other programs under an agreement signed with Iraq two years ago.

Among the least visible but most valuable US assistance to Iraq is the political support that Washington has and can wield at the United Nations and in other forums to shield Iraqi assets from financial claims, settle Hussein-era disputes involving Kuwait, and have Iraq admitted to the World Trade Organization.