The motivation for Muqtada al-Sadr, an Iraqi Shia Muslim scholar, to meet the Saudi crown prince last month was an attempt to roll back Iranian influence in Iraq, seek a leadership role and tone down sectarianism between the two countries, analysts say.

Sadr, who is openly hostile to the United States, was hosted on July 30 by Saudi Arabia's Crown Prince Mohammed bin Salman.

The reason behind the gathering in Jeddah centred on a shared interest in countering Iranian influence in Iraq, Baghdad-based analyst Ahmed Younis said.

"Sadr's visit to Saudi Arabia is a bold shift of his policy to deliver a message to regional, influential Sunni states that not all Shia groups carry the label 'Made in Iran'."

For Sadr, who has a large following among the poor in Baghdad and southern Iraqi cities, it was part of efforts to bolster his Arab and nationalist image ahead of elections where he faces Shia rivals close to Iran.

"This is both a tactical and strategic move by Sadr. He wants to play the Saudis off against the Iranians, shake down both sides for money and diplomatic cover," said Ali Khedery, who was a special assistant to five US ambassadors in Iraq.

READ MORE: Is the time right for Saudi-Iran rapprochement?

Ultimately, Sadr seeks a leadership role in Iraq that would allow him to shape events without becoming embroiled in daily administration, which could erode his popularity, diplomats and analysts say.

Days after the Jeddah meeting, Sadr met Sheikh Mohammed bin Zayed Al Nahyan, Crown Prince of Abu Dhabi, who has also taken an assertive line against Iran, the dominant foreign power in Iraq since the 2003 US invasion ended Sunni minority rule.

Iran has since increased its regional influence, with its forces and allied fighters spearheading the fight against the Islamic State of Iraq and the Levane (ISIL, also known as ISIS) and holding sway in Baghdad.

READ MORE: Saudi Arabia 'seeks Iraq's help' to mend ties with Iran

For Saudi Arabia, less Iranian influence in Iraq would be a big win in a rivalry that underpins conflict across the Middle East.

"There are plans to secure peace and reject sectarianism in the region," Sadr told the Saudi-owned Asharq al-Awsat newspaper last week, saying that it was "necessary to bring Iraq back into the Arab fold".

When asked what Saudi Arabia hoped to achieve with Sadr's recent visit to the Kingdom and the United Arab Emirates, a Saudi official at the Saudi embassy in Washington said: "Saudi Arabia hopes to encourage Iraqis to work together to build a strong resilient and independent state. With that in mind, it will reach out to any party who could contribute to achieving that goal".

Limited Influence

A politician close to Sadr said the Jeddah meeting was aimed at building confidence and toning down sectarian rhetoric between the two countries.

The rapprochement is "a careful testing of the waters with the Abadi government and some of the Shia centres of influence like Sadr and the interior minister," said Ali Shihabi, executive director of the Washington-based Arabia Foundation.

READ MORE: The return of Muqtada al-Sadr

Another sign of rapprochement is an agreement to increase direct flights to a daily basis.

Iraqi Airways hopes to reopen offices in Saudi airports to help Iraqis travel to the kingdom, especially for pilgrimages, Iraq's transport ministry said.

As OPEC producers, the two countries cooperated in November to support oil prices. Their energy ministers discussed bilateral cooperation and investment last week.

Iranian reaction to the meetings has however been minimal.

"Iraqi personalities and officials do not need our permission to travel outside of Iraq or to report to us," foreign ministry spokesman Bahram Qasemi said last week, according to the semi-official Fars news agency.