DUBAI, May 27 (Reuters) - Iran's hardline Supreme Leader Ayatollah Ali Khamenei said on Saturday Saudi Arabia's rulers faced "certain downfall" for aligning themselves with the United States, hours after the country's pragmatist president called for improved ties with Gulf states.

"They (Saudi leaders) act cordially towards the enemies of Islam while having the opposite behaviour towards the Muslim people of Bahrain and Yemen," Khamenei told a religious gathering, according to his Twitter account.

"They will face certain downfall," he told a Koran reading event marking the start of the Muslim fasting month of Ramadan.

Iran and the Gulf Arab states are backing opposing sides in the wars in Syria and Yemen, and the unrest in Bahrain. Relations were further hit last weekend when U.S. President Donald Trump visited Saudi Arabia and accused Tehran of supporting terrorism in the Middle East.

Iran denies such accusations and says Saudi Arabia, its arch-foe, is the real source of funding for Islamist militants.

Meanwhile President Hassan Rouhani, a pragmatist who has significantly less power than the supreme leader, earlier called for improved relations with Gulf Arab states during a telephone call with the emir of Qatar, which has come under fire from its Gulf neighbours over its relationship with Tehran.

"We want the rule of moderation and rationality in the relations between countries and we believe that a political solution should be a priority," the state news agency IRNA quoted Rouhani as telling Qatari Emir Tamim bin Hamad al-Thani.

"The countries of the region need more cooperation and consultations to resolve the crisis in the region and we are ready to cooperate in this field," Rouhani told Sheikh Tamim, IRNA added.

Rouhani earlier responded to Trump's criticism by saying stability could not be achieved in the Middle East without Iran's help.

Saudi Arabia and the United Arab Emirates expressed exasperation this week after official Qatar media published remarks purported to have been made by Sheikh Tamim which were critical of Trump's foreign policy and of renewed tensions with Tehran.

Qatar said the remarks, published late on Tuesday, were fake and that the news agency that ran them had been hacked.

(Reporting by Dubai newsroom; Editing by Gareth Jones) ((dubai.newsroom@thomsonreuters.com))