TEHRAN - President Hassan Rouhani praised Monday the strategic role played in recent elections by Mohammad Khatami, Iran's ex-president who is subject to a media ban, thanking him in a speech aired live on state television.

Rouhani's remarks, during a visit to Yazd, the home town of Khatami, Iran's only reformist president, prompted cheers from the crowd but the sound of their applause during the broadcast was lowered several times.

Iranian media are forbidden on the orders of Tehran's prosecutor from publishing pictures of Khatami, president between 1997 and 2005, or quoting his words, on account of his support for the defeated reformist candidates in the disputed 2009 re-election of Mahmoud Ahmadinejad.

Regardless of the restrictions Khatami was a guiding influence in the success of pro-Rouhani reformist politicians in last month's elections which reduced conservative dominance in Iran's parliament.

He circumvented the ban and used YouTube and the smartphone message sharing app Telegram to urge Iranians to back reformists, also naming the group's candidates as representing a "List of Hope" for Iran.

"After the honourable leader, who had the main role in mobilising people to the ballot boxes, all elites, elders, and in particular the pride of this town, invited people in this election to create a great epic," Rouhani said, alluding to Khatami before naming him outright.

"When I entered parliament those individuals whom you brave people of Yazd province had sent to the parliament were shining flowers and lights... and in that very parliament, from Ardakan, was my dear brother Seyed Mohammad Khatami," the president added.

"Heroic Iran shall never forget its servants, those who worked for Iran's glory. They are, today, regarded as the pride of the land and no one can silence their name and their greatness."

Social media showed banners of Khatami and Rouhani were held up by the crowd during the speech but they could not be seen on the live broadcast.

Rouhani was accompanied on the trip by Mohammad Reza Aref, a vice president during Khatami's administration, who led the List of Hope's candidates during the February 26 elections.

The group swept Tehran, winning all 30 seats in the capital, and made large gains in other cities and provinces.

The media ban on Khatami remains controversial. Iran's judiciary is independent of the government but a spokesman for Iran's Ministry of Culture and Islamic Guidance, quoted by the ISNA news agency on Monday, echoed Rouhani's remarks.

Asked about the ban on Khatami's image and his role in encouraging people to vote, ministry spokesman Hossein Nooshabadi said: "We are thankful for the presence of all distinguished figures and scientific, political and cultural personalities who encouraged people and had a role in the election."