BAGHDAD (AP) — Iranian President Hassan Rouhani arrived in Baghdad on Monday, Iraqi state television said, making his first official visit to the nation that Tehran once fought a bloody war against and later backed in the battle with the Islamic State group.

Since Rouhani’s election in 2013, Iraq has relied on Iranian paramilitary support to fight IS, following the militant group’s capture of the Iraqi city of Mosul and other territory in both Iraq and Syria.

Now with the militants facing a final territorial defeat in the Syrian village of Baghouz, Iran is looking for Iraq’s continued support as it faces a maximalist pressure campaign by President Donald Trump after his decision to withdraw America from Tehran’s nuclear deal with world powers.

Rouhani, who is accompanied on the three-day visit by a high-ranking political and economic delegation, was received by an honor guard on landing in Baghdad, where he was welcomed by Iraqi Foreign Minister Mohammed Ali Al-Hakim.

He is to first visit a Shiite shrine in the Iraqi capital and then meet with both President Barham Salih and Prime Minister Abdel Abdul Mehdi, as well as visit other politicians and Shiite leaders.

Rouhani’s visit underscores how much has changed since the 1980s, when Iraqi dictator Saddam Hussein invaded Iran, sparking an eight-year war that killed 1 million people. After the 2003 US-led invasion of Iraq toppled Saddam, Iran began a campaign of backing militants who targeted American forces in Iraq.

Tehran also made political connections with Iraq’s Shiite leaders, who had been persecuted by Saddam’s government. Iran’s former hard-line president Mahmoud Ahmadinejad became the first Iranian president to visit Iraq on a trip in 2008.

Iraq and Iran share a 1,400-kilometer-long (870 miles) border. Trump made a snap December trip to Iraq and made comments that US forces should stay in Iraq to keep an eye on Iran, something dismissed by both Iran and Iraqi leaders, whom Trump did not meet on the visit.

Speaking at Tehran’s Mehrabad Airport before leaving for Iraq, Rouhani’s official website quoted him as saying the trip’s goal was “deepening bilateral relations.”

“Relations between Iran and Iraq are special,” Rouhani was quoted as saying. “In the recent years, the people of Iran have passed a test with pride, and that is wherever the peoples of the region faced a problem and asked for the help of the Iranian nation and government, we rushed to help them.”

Rouhani, who had visited Iraq privately before becoming president, had planned an official visit in 2016 but it was canceled over unspecified “executive” problems.

This time, Rouhani, who is on a second four-year-term, is particularly vulnerable because of the economic crisis assailing the Iranian rial, which has hurt ordinary Iranians and emboldened critics to openly call for the president’s ouster.

Tehran sees the US military presence at its doorstep in Iraq as a threat — one that could also undermine Iran’s influence over Baghdad.

Iranian Foreign Minister Mohammad Javad Zarif alluded to that on Sunday while in Baghdad, saying that any country which tries to interfere with the good Iran-Iraq relations would “be deprived of opportunities for itself.”

Iran also sees Iraq as a possible route to bypass US sanctions that Trump re-imposed last year after pulling the US out of the 2015 nuclear deal.

Last year, Iran’s exports to Iraq amounted to nearly $9 billion. Tehran hopes to increase the roughly $13 billion volume in trade between the two neighboring countries to $20 billion. Also, some 5 million religious tourists bring in nearly $5 billion a year as Iraqis and Iranians visit Shiite holy sites in the two countries.