US President Barack Obama vowed an "enduring" partnership with a "self-reliant" and sovereign Iraq, touting his promise kept to end a wrenching war as he met Prime Minister Nuri al-Maliki.
Obama said the last US soldiers would leave Iraq this month "with heads held high" but left history to judge the decision to wage a conflict he made his name opposing. He also warned Iran not to meddle in Iraq's affairs.
"After nearly nine years, our war in Iraq ends this month," Obama said, saying it was time to make some new history between the United States and Iraq with an "equal partnership" of military, security and economic ties.
"Mr Prime Minister, as we end this war, and as Iraq faces its future, the Iraqi people must know that you will not stand alone. You have a strong and enduring partner in The United States of America."
Maliki's visit symbolized the end of an episode that cleaved deep divisions in American politics, stained the US image abroad and sparked sectarian carnage while killing nearly 4,500 US troops and tens of thousands of Iraqis.
"Just as Iraq has pledged not to interfere in other nations, other nations must not interfere in Iraq," Obama said, in a clear warning to Iran not to try to meddle in its neighbor's affairs.
Maliki and Obama later made a joint visit to Arlington National Cemetery in Virginia, where many of the US war dead are buried.
Obama's vow to end the war launched by his predecessor George W. Bush in 2003 became the bedrock promise that underpinned his lightning rise from political obscurity to the presidency in 2008.
When he took office, more than 150,000 US troops were still in Iraq, but the president said the last of them would be home by the Christmas holidays after he made good on his vow to end the war "responsibly."
Obama is touting his fulfilled vow to voters who must decide next year whether to give him a second term, even though he has failed to restore full prosperity after the worst economic crisis in decades.
Washington wanted to partner with Iraq on its security, in trade and commerce, and to strengthen its fledgling democratic political institutions and armed forces, Obama said.
Signup to our newsletter and follow us on Facebook and Twitter!
Officials said Iraq would buy a second batch of 18 F-16 warplanes from the United States as it seeks to secure its own airspace, and Obama offered a firm relationship between the two militaries.
"Iraq today has a lot of wealth and it needs experience and expertise, and American and foreign expertise to help it exploit its own wealth," said Maliki, adding he hoped US oil firms could help tap Iraq's vast resources.
Maliki said the full US withdrawal was proof of "success" and was not a failure as some of Obama's political opponents have argued.
"The goals that we established were achieved," Maliki said.
The full withdrawal from Iraq was mandated under an agreement concluded by the Bush administration.
But long-running talks designed to provide for a future US training mission failed over the issue of providing legal immunity for American soldiers.
"Both men have failed in their responsibilities with regard to our shared security interests," Republican Senator John McCain complained, diagnosing a lack of "vision, commitment, and leadership" in Washington and Baghdad.
Around 6,000 US troops remain stationed in Iraq on three bases, down from peaks of nearly 170,000 soldiers and 505 bases. All the troops must leave by the end of the month.
The US military leaves behind an Iraqi security force with more than 900,000 troops, which both sides say is capable of maintaining internal security but cannot defend the country's borders, airspace or maritime territory.
Some 157 uniformed US soldiers and up to 763 civilian contractors will remain to help train Iraqi forces under the authority of the sprawling US embassy in Baghdad.
The US leader and Maliki could not agree with one another on Syria, with which Iraq has a close relationship.
Obama reiterated his view that President Bashar al-Assad had ceded legitimacy with his crackdown on protesters and should step down.
Maliki said that though Syrians deserved to pursue democratic freedoms just as Iraqis had, he had no "right" to demand another leader's ouster.
Obama will mark the final withdrawal of all US troops from Iraq by addressing returning soldiers on Wednesday at a base in North Carolina.