Saudi Arabia's foreign minister has made a rare visit to Baghdad in an attempt to mend the kingdom's tense relations with Iraq.

Adel al-Jubeir's surprise trip on Saturday marked the first official visit by a Saudi foreign minister since 1990, and the first high-level visit since the 2003 US-led invasion.

"It's the hope of the Kingdom of Saudi Arabia to build excellent relations between the two brotherly countries," said Jubeir.

"There are also many shared interests, from fighting extremism and terrorism [to] opportunities for investment and trade between the two countries."

Jubeir, who met his Iraqi counterpart Ibrahim al-Jaafari and Prime Minister Haider al-Abadi, also announced Saudi plans to appoint a new ambassador to Iraq.

An Iraqi foreign ministry official said the kingdom supported the resumption of direct flights between the two countries.

READ MORE: Can Iraq survive the Iran-Saudi row?

Abadi, who has been in power since 2014, has supported efforts to improve strained ties, but the road to normalisation has been rocky.

Ambassador spat

Thamer al-Sabhan, Saudi Arabia's previous ambassador to Iraq, was removed in August.

Sabhan's comments about Iran's involvement in Iraqi affairs and the alleged persecution of Sunni Muslims had angered Iraq's local Shia politicians and militia leaders.

Sabhan had also called on Iraq to exclude Shia paramilitary groups from its military campaign against the Islamic State of Iraq and the Levant (ISIL, also known as ISIS), in order to avoid abuses against Sunnis in the country.

Sabhan was the first ambassador appointed by Saudi Arabia after it reopened its embassy in Baghdad in 2015, following a 25-year break.

Saudi has long accused Iraq of being too close to Iran, its main regional rival, and of encouraging sectarian discrimination against the Sunnis, a charge the Shia-led government in Baghdad denies.

Previously, Jubeir himself accused the Hashd al-Shaabi militia, a main partner of the Iraqi army in its fight against ISIL, of being a proxy force for Iran, prompting Baghdad to accuse him of meddling in Iraqi affairs.

READ MORE: Iran accused of undermining Middle East security

Since the fall of Saddam Hussein's government in 2003, Iran has advanced its influence in Iraq, which has further strained relations with Saudi Arabia.

Iran has helped Iraq in the fight against ISIL, while supporting the powerful Shia militias in the country.

In turn, Iraq has often suffered from being turned into a battlefield where the rivalry of its neighbours are played out.

Ali Khedery, the former special assistant to five US ambassadors to Iraq, told Al Jazeera that Iran was likely to be suspicious of Jubeir's visit.

"[Iran] will possibly move to guard the gains they consolidated in [Iraq], which might lead to outbursts of additional violence that target Arab Gulf states' interests in the country," Khedery said.

Cooperation against ISIL

Jubeir's visit comes amid a major Iraqi offensive to recapture the ISIL-held city of Mosul.

During Saturday's meetings, both sides discussed cooperating in the fight against ISIL.

Jubeir expressed his country's support for an ongoing US-backed Iraqi campaign aimed at dislodging the group from Iraq, according to Abadi's official statement.

A day earlier, Iraqi forces punched through the defences of the last ISIL stronghold in Mosul.

Defeating ISIL in Mosul would roll back the self-styled caliphate it declared in Iraq and Syria in 2014 after seizing large parts of both countries.

About 100,000 Iraqi soldiers, security forces, Kurdish Peshmerga fighters, and mainly Shia paramilitary forces are participating in the Mosul campaign that began on October 17.