Vice President Biden and Iraqi Prime Minister Nouri al-Maliki, speaking at a joint ceremony outside Baghdad on Thursday to commemorate the imminent end of the Iraq war, urged Iran and other neighboring countries not to attempt to exploit the departure of U.S. troops to expand their own influence here.

The ceremony was held in the al-Faw Palace, built by Saddam Hussein and now the U.S. military’s headquarters at Camp Victory, the nerve center of American power in Iraq for the past 81 / 2 years.

Within days, the vast camp that has been home to tens of thousands of U.S. troops over the years will be handed over to Iraqi control, U.S. military spokesman Col. Barry Johnson said, as the countdown begins in earnest for all U.S. troops to leave by the end of the month under the terms of the bilateral security agreement signed in 2008.

There are just 12,000 U.S. troops left in Iraq, down from a peak of 170,000 in 2007, and Americans are at only six bases, down from more than 500 at the height of the war, Johnson said.

Concerns that neighboring Iran will seek to fill the vacuum left by the departing Americans are foremost in the minds of U.S. policymakers as upheaval in the region threatens to reignite the sectarian divide between Iraq’s dominant Shiites and the Sunnis ousted from power by the U.S.-led invasion.

Biden, who is on an unannounced visit here, referred to Iran in his speech to the gathering of top Iraqi officials, lawmakers and U.S. and Iraqi troops, saying he was confident Iraq did not want to substitute domination by one foreign power for that of another.

“The Iraqi people will not, have not, and will not again yield to any external domination, and they would never abide another nation violating their sovereignty by funding and directing militias that use Iraqi terrain for proxy battles that kill innocent Iraqi civilians,” he said.

“Militias” is the term U.S. and Iraqi officials use to refer to the Shiite groups that took up arms in the early years of the war with support and funding from Shiite Iran. Some have continued to attack Americans even as they leave, targeting convoys with roadside bombs and firing rockets at the dwindling number of U.S. bases.

Maliki echoed the same sentiments in his speech, alluding to the way the Iranian-backed groups have cited the presence of America’s troops to justify violence.

“The withdrawal operation will take away all the slogans that some countries hide behind in order to interfere in the internal affairs of Iraq,” he said.

Reflecting concerns that some of Iraq’s other powerful neighbors, including Sunni Saudi Arabia and Turkey, will also compete to influence Iraq, Maliki said he wanted good relations with “all brotherly and friendly countries, especially the neighboring countries.”

As the ceremonies got underway, 20 people were reported killed in two separate attacks in the province of Diyala. A car bombing killed 13 people, and an attack on the homes of three Sunni Awakening fighters killed seven others, provincial police said.

The ending of the war “doesn’t mean that the threats are over,” Biden said. “But Iraqi security forces have been well-trained, prepared, and you are fully capable of meeting the challenges.”