BAGHDAD -- Iranian President Hassan Rouhani was in Baghdad on Monday, 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.
Rouhani then visited the shrine of Imam Kadhim, the seventh of 12 clerics revered by Shiites worldwide. Rouhani, a Shiite cleric himself, paused to reach out and touch the gate surrounding the imam's tomb.
He then met President Barham Salih and spoke to journalists, telling them that a "stable Iraq will lead to stability in the entire region."
"We want to be united countries, not against others, but attracting others to our unity," Rouhani said.
For his part, Salih said Baghdad's central location made it crucial to resolving regional issues. He thanked Iran for its support during Iraq's fight against IS.
"The victory that was achieved against IS group in Iraq was an important and huge victory, but incomplete as the eradication of that sick, deviated line of thought and extremism require more sustainable regional efforts and cooperation," Salih said.
Rouhani was to later meet Prime Minister Abel Abdul-Mehdi. He plans on meeting with other politicians and Shiite leaders during his visit.
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 an estimated 1 million people. After the 2003 U.S.-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 U.S. 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 cancelled 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 U.S. 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 U.S. sanctions that Trump re-imposed last year after pulling the U.S. 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.
"This visit seeks to send a message to the United States of America that Iran is still effective in Iraqi politics," said Ali Fadlallah, an analyst in Iraq. "I think the visit (also) aims at settling the trade and economic relation. Iran wants to be partner in building up the infrastructure and the cities that were damaged by the war on terrorism."
Associated Press writer Nasser Karimi in Tehran, Iran, contributed to this report.