DUBAI (Reuters) - Iran’s top leader Ayatollah Ali Khamenei urged Iraq on Saturday to demand U.S. troops leave “as soon as possible”, during a visit by Iraqi Prime Minister Adel Abdul Mahdi that showed off Tehran’s strong influence in Baghdad despite U.S. pressure.

FILE PHOTO: Supreme Leader Ayatollah Ali Khamenei delivers a speech on the first day of Persian New Year, also known as Nowruz in Mashhad, northeast of Tehran, Iran March 21, 2019. Khamenei.ir/Handout via REUTERS

Iran and the United States have been competing for clout in Iraq since the U.S.-led invasion in 2003 that toppled dictator Saddam Hussein, an enemy of both countries.

Many of Iraq’s leaders, from its Shi’ite majority, have close ties with Iran, the main Shi’ite power in the Middle East. Over the past four years, both Iran and the United States helped Iraq defeat Islamic State fighters that captured a third of Iraq in 2014.

“You must make sure that the Americans withdraw their troops from Iraq as soon as possible because expelling them has become difficult whenever they have had a long military presence in a country,” Khamenei was quoted as saying by state media.

“The Iraqi government, parliament and current political activists in the country are undesirable for the Americans ... and they are plotting to remove them from Iraqi politics,” said Khamenei.

Iran and Iraq fought a devastating 1980-88 war but the 2003 U.S.-led invasion prompted a long Sunni Islamist insurgency during which Iran’s regional sway rose at Washington’s expense.

The long enmity between Iran and the United States worsened further following President Donald Trump’s decision last year to pull out of an international accord curbing Tehran’s nuclear program and to reimpose economic sanctions on Iran.

During Abdul Mahdi’s visit, President Hassan Rouhani called for Iran and Iraq to expand their gas and electricity dealings and boost bilateral trade to $20 billion.

“The plans to export electricity and gas and hopefully oil continue and we are ready to expand these contacts not only for the two countries but also for other countries in the region,” Rouhani said in remarks carried by state TV.

In March, the United States granted Iraq a 90-day waiver exempting it from sanctions to buy energy from Iran, the latest extension allowing Baghdad to keep purchasing electricity from its neighbor.

“We hope that our plans to expand trade volume to $20 billion will be realized within the news few months or years,” Rouhani said. Iranian media reports have put the current level of trade at about $12 billion.

Rouhani also expressed hope that work on building a railway linking the two countries would begin within the next few months. The railway project was part of deals reached during Rouhani’s March visit to Baghdad.

Iraq relies heavily on Iranian gas to feed its power stations, importing roughly 1.5 billion standard cubic feet per day via pipelines in the south and east.