By Ahmed Rasheed and Sylvia Westall
BAGHDAD/DUBAI (Reuters) - It was an unusual meeting: An Iraqi Shi'ite Muslim cleric openly hostile to the United States sat in a palace sipping juice at the invitation of the Crown Prince of Saudi Arabia, the Sunni kingdom that is Washington's main ally in the Middle East.
For all the implausibility, the motivations for the July 30 gathering in Jeddah between Moqtada al-Sadr and Crown Prince Mohammed bin Salman run deep, and centre on a shared interest in countering Iranian influence in Iraq.
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 Shi'ite rivals close to Iran.
For the newly elevated heir to the throne of conservative Saudi Arabia, the meeting - and talks with Iraqi Prime Minister Haider al-Abadi in June - is an attempt to build alliances with Iraqi Shi'ite leaders in order to roll back Iranian influence.
"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 Shi'ite groups carry the label 'Made in Iran'," said Baghdad-based analyst Ahmed Younis.
This policy has assumed greater prominence now that Islamic State has been driven back in northern Iraq, giving politicians time to focus on domestic issues ahead of provincial council elections in September and a parliamentary vote next year.
"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 U.S. ambassadors in Iraq.
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.
Such a role - religious guide and political kingmaker - would fit with the patriarchal status the Sadr religious dynasty has for many Shi'ite Arabs in Iraq, Lebanon, Kuwait and Bahrain.
Days after the Jeddah meeting, Sadr met Sheikh Mohammed bin Zayed al-Nahayan, Crown Prince of Abu Dhabi, who has also taken an assertive line against Tehran, the dominant foreign power in Iraq since the 2003 U.S. invasion ended Sunni minority rule.
Iran has since increased its regional influence, with its forces and allied militias spearheading the fight against Islamic State in Iraq and Syria and holding sway in Baghdad.
For Saudi Arabia, which sees itself as the bastion of Sunni Islam, 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 UAE, 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."
Washington supports the Saudi-Iraq rapprochement, but the embracing of Sadr raises questions about whether it sees a man known for his anti-Americanism as a reliable figure.
"It is perhaps close to a necessary evil," a U.S. official said of the visit, although he said it was a "very uncomfortable position for us to be in" due to Sadr's anti-Americanism, which had led to the deaths of U.S. citizens.
"His visits to the region, and broadly the high-profile visits by Iraq, those things broadly are good, in that they get Iraq facing the Gulf nations and they help to turn their attention away from Iran," the official said.
A second U.S. official said that Washington viewed the visits positively, "not because we're Sadr fans but because we've been pushing Saudi Arabia to mend fences and open gates with Iraq".
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.
How far detente can go is unclear: Iran has huge political, military and economic influence in Iraq. Saudi Arabia is playing catch-up, having reopened an embassy in Baghdad only in 2015 after a 25-year break caused by the Iraqi invasion of Kuwait.
Whatever the Saudis and Gulf states do, "Iran will stay the key player in Iraq for at least the next 10 years," said Wathiq al-Hashimi, chairman of the Iraqi Group for Strategic Studies think-tank.
Khedery said Saudi Arabia and the other Gulf states were not skilled at exerting external influence.
"They usually just throw money at issues and the beneficiaries of that largesse become very, very wealthy and that's it," he said. The Iranians in Iraq offered intelligence, diplomatic support and cash and wielded "big sticks" against anyone stepping out of line, he said.
Still, the Jeddah meeting has produced practical results.
Sadr's office said there was an agreement to study investment in Shi'ite regions of southern Iraq. Riyadh will also consider opening a consulate in Iraq's holy Shi'ite city of Najaf, Sadr's base.
Saudi Arabia would donate $10 million to help Iraqis displaced by the war on Islamic State in Iraq, Sadr said, while Iraq's oil minister said Riyadh had discussed building hospitals in Basra and Baghdad.
After the Saudi trip, Sadr again urged the Iraqi government to dismantle the Tehran-backed Shi'ite paramilitary groups involved in the fight against Islamic State - a theme that is expected to become a top election issue.
A source from Sadr's armed group told Reuters that after the visit orders were issued to remove anti-Saudi banners from its headquarters, vehicles and streets.
Sadr had called on the Saudis to "stop hostile speeches by fanatical hardline clerics who describe Shi'ites as infidels," and Crown Prince Mohammed had promised efforts towards this, the politician close to Sadr said.
It remains to be seen how far Saudi Arabia can prevent anti-Shi'ite outbursts by its media or on social media, since Wahhabism, the kingdom's official ultra-conservative Sunni Muslim school, regards Shi'ism as heretical.
But the Saudi minister of state for Gulf affairs, Thamer al-Subhan, called for tolerance after greeting Sadr, using Twitter to decry "Sunni extremism and Shi'ite extremism".
Saudi Arabia this week cracked down on Twitter users, including a radical Sunni cleric who published insulting comments about Shi'ites.
As part of the wider detente, Iraq and Saudi Arabia announced last month they are setting up a council to upgrade strategic relations.
The Saudi cabinet has approved a joint trade commission to look at investment while a Saudi daily reported the countries planned to reopen a border crossing shut for more than 25 years - a point raised by Sadr on his visit.
Brett McGurk, U.S. special envoy for the coalition against Islamic State, tweeted earlier on Wednesday that he had visited the Iraq-Saudi border: "Closed since '90. ISIS attacked in '15. Today: secure, re-open, bustling w/1200 pilgrims per day."
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.
Then there is coordination on energy policy.
As OPEC producers, the two cooperated in November to support oil prices. Their energy ministers discussed bilateral cooperation and investment last week.
Iranian reaction to the meetings has 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.
(Additional reporting by Maher Chmaytelli in Erbil, William Maclean and Rania El Gamal in Dubai and Yara Bayoumy in Washington; Editing by Giles Elgood and Leslie Adler)