Security and military co-operation were high on the agenda during a recent series of meetings between senior Iraqi and Saudi officials, conducted in the aftermath of a January attack on Riyadh that was claimed by an Iranian proxy.
These threats were at the centre of the discussions during Iraqi Prime Minister Mustafa Kadhemi's March 31 visit to Riyadh, according to Iraqi security expert and former military officer Majid al-Qaisi.
The visit came after a January 23 attack in which drones were launched at al-Yamamah Palace and other locations in Riyadh in an attack claimed by Alwiyat al-Waad al-Haq, a new front group for Iran-backed Iraqi militia Kataib Hizbullah.
Speaking at a press conference in Riyadh, Kadhemi said Iraq would not allow its territory to be used as a launchpad for any attack on Saudi Arabia.
Separately, in a sign of warming ties between the two neighbours, Iraq and Saudi Arabia concluded five agreements to enhance trade, economic co-operation and investment during Kadhemi's visit.
They also announced the establishment of a joint fund to promote investment in Iraq, with a $3 billion Saudi contribution.
The countries also agreed to maintain energy co-operation to maintain stability in global oil markets, a joint statement added.
On February 22, Iraqi Interior Minister Othman al-Ghanmi and Foreign Minister Fouad Hussein visited the kingdom to meet with their Saudi counterparts, while on March 2, Saudi Chief of Staff Fayyad al-Ruwaili visited Baghdad.
The aim of these mutual visits was to enhance security co-operation and exchange intelligence regarding the January 23 attack, al-Qaisi said.
"Saudi Arabia has concerns about the proliferation of Iran-backed groups near its borders and views them as a threat to its national security," al-Qaisi said.
He noted that boosting relations with Saudi Arabia "is an important gain for Iraq and a step in the right direction".
A worrying challenge
Saudi Arabia seeks to open its doors to Iraq, but Iran is constantly trying to close them by directing its militias to carry out hostile acts, said political analyst and former Iraqi MP Taha al-Lahibi.
He noted that Abu Ali Al-Basri, a Kataib Hizbullah commander, had praised the January 23 attack in a post on the social media platform Twitter.
This type of reaction is evidence of the malicious role this militia plays in threatening the security of the region and violating Iraq's sovereignty, he said.
Iran fears any rapprochement between Iraq and Saudi Arabia would hurt its economic interests, as it seeks to continue to supply Iraq with electricity and gas at high prices, al-Lahibi said.
Saudi Arabia and Iraq reopened the Arar border crossing for trade for the first time in three decades in November last year.
As the two countries continue to work more closely, they face a worrying challenge: the proliferation of Iran-aligned militias in the desert areas near the border, especially in the town of al-Nukhayb, across from the Saudi city of Arar.
This area is a major gathering point for the militias, led by Kataib Hizbullah, with hundreds pouring in to the town since 2015 to impose their control.
Iran-backed militias such as Kataib Jund al-Imam, Saraya Ashura and Asaib Ahl al-Haq also have a presence in the desert along Iraq's 814-kilometre border with Saudi Arabia, near areas like Jdeydet Arar, Biyar Ali, Naqrat al-Salman and al-Faisaliah.
The militias occupy military barracks that have been deserted since 2003, using them to run their operations and store their weapons, which reportedly include 1,400 rockets.
The militias claim they provide security to convoys of pilgrims and take part in Iraqi army operations against "Islamic State of Iraq and Syria" (ISIS) holdouts.
But they have been accused of carrying out cross-border attacks on targets inside Saudi territory.