BAGHDAD -- When U.S. Secretary of State Mike Pompeo sat down with Iraqi officials in Baghdad last week as tensions mounted between America and Iran, he delivered a nuanced message: If you're not going to stand with us, stand aside.

The message, relayed to The Associated Press by two Iraqi government officials, underscores Iraq's delicate position: Its government is allied with both sides of an increasingly contentious confrontation.

As tensions escalate, there are concerns that Baghdad could once again get caught in the middle, just as it is on the path to recovery. The country hosts more than 5,000 U.S. troops, and is home to powerful Iranian-backed militias, some of whom want those U.S. forces to leave.

"The big question is how Iraqi leaders will deal with (their) national interests in a country where loyalty to external powers is widespread at the expense of their own nation," Iraqi political analyst Watheq al-Hashimi said. "If the state cannot put these (Iranian-backed militias) under control, Iraq will become an arena for an Iranian-American armed conflict."

Despite the escalation of rhetoric by both sides, U.S. President Donald Trump has said he doesn't want a war with Iran and has even said he is open to dialogue. But tension remains high, in part given the region's fraught history.

For Iraq to be a theatre for proxy wars is not new. The Shiite-majority country lies on the fault line between Shiite Iran and the mostly Sunni Arab world, led by powerhouse Saudi Arabia, and has long been a battlefield in which the Saudi-Iran rivalry for regional supremacy played out.

During America's eight-year military presence that began with the 2003 invasion of Iraq, U.S. troops and Iranian-backed militiamen fought pitched battles around the country, and scores of U.S. troops were killed or wounded by the militia forces armed with sophisticated Iranian-made weapons.

American forces withdrew from Iraq in 2011 but returned in 2014 at the invitation of Iraq to help battle the Islamic State group after it seized vast areas in the north and west of the country, including Iraq's second-largest city, Mosul. A U.S.-led coalition provided crucial air support as Iraqi forces regrouped and drove IS out in a costly three-year campaign. Iranian-backed militias fought alongside U.S.-backed Iraqi troops against IS, gaining outsized influence and power.

Now, amid an escalating conflict between the U.S. and Iran, Iraq is once again vulnerable to becoming caught up in the power play. An attack targeting U.S. interests in Iraq would be detrimental to the country's recent efforts at recovering and reclaiming its status in the Arab world.

Earlier this year, Trump provoked outrage in Baghdad when he said he wanted U.S. troops to stay in Iraq so they can "watch Iran," suggesting a changing mission for American troops there.

On May 8, Pompeo made a lightning, previously unannounced trip to the Iraqi capital following the abrupt cancellation of a visit to Germany, and as the United States had been picking up intelligence that Iran is threatening American interests in the Middle East.

The two Iraqi officials said Pompeo relayed intelligence information the U.S. had received about a threat to U.S. forces in Iraq -- but kept it vague. They said he did not specify the nature of the threat. The officials, speaking on condition of anonymity to divulge confidential information, said Pompeo told the Iraqis that America did not expect them to side with the U.S. in any confrontation with Iran, but that they should not side against America. In other words, stand aside.

A few days later, as U.S.-Iranian tensions continued to rise, the State Department ordered all non-essential, non-emergency government staff to leave the country.

U.S. officials said Pompeo told the Iraqis the U.S. had an "inherent right to self-defence" and would use it if U.S. personnel, facilities or interests are attacked by Iran or its proxies in Iraq or anywhere else.

The three officials, who were not authorized to publicly discuss the private meetings in Baghdad and spoke on condition of anonymity, said Pompeo was not contemplating any pre-emptive strikes on Iran or the use of Iraqi territory to stage military operations against Iran. Pompeo's message, the officials said, was that the U.S. wants to avoid conflict but would respond or defend itself if necessary.

The secretary told reporters on the flight that his meetings with Iraq's president and prime minister were intended to demonstrate U.S. support for "a sovereign, independent" Iraq, free from the influence of neighbouring Iran. Pompeo also said he wanted to underscore Iraq's need to protect Americans in their country.

A general at Iraq's Defence Ministry said Iraq was taking precautionary security measures in light of the information about threats against U.S. interests, although those measures have not reached the highest levels.

"Iraqi forces are worried that American forces could be targeted by factions loyal to Iran," said the official, who spoke on condition of anonymity because he was not authorized to speak to the media. He added that any attack on U.S. troops could come as retaliation if the United States were to carry out a military operation against Iran.

The heightened tensions between Iran and the U.S. come a year after Trump pulled America out of Tehran's nuclear deal with world powers and as the White House ordered an aircraft carrier and bombers into the region over a still-unexplained threat from Iran.

On Sunday, the United Arab Emirates alleged that four oil tankers off its eastern coast were targeted by sabotage. On Tuesday, Yemen's Iran-allied Houthi rebels said they launched seven drones to target Saudi Arabia. The drones stuck pumping stations along the kingdom's crucial East-West Pipeline, causing minor damage, Saudi officials say.

On the streets of Baghdad, some shrugged off the rising tensions while others worried their country could be sucked into another war.

Aqil Rubaei said he was worried that his country, which has been at war since a year before he was born, will be the place where the U.S. and Iran will settle their accounts. The 38-year-old was born in 1981, a year after Iran and Iraq began their eight-year war and was 9 years old when Saddam Hussein's forces invaded Kuwait leading to a destructive war that forced Iraq out of Kuwait and 13 years of crippling sanctions.

In 2003, the U.S. invaded and removed Saddam, leading to the rise of extremist groups that culminated in 2014 with the Islamic State group capturing large parts of Iraq and Syria and declaring a so-called caliphate. The war that followed left entire Iraqi cities and towns destroyed until Iraq declared victory in 2017.

"Iraqi people are fed up with war," said Rubaei inside his cosmetics shop in Baghdad's Karrada neighbourhood. "We don't want Iraq to become an arena for an Iranian-American war."

------

Associated Press writer Matthew Lee in Washington contributed to this report.