Image copyright Getty Images Image caption President Rouhani's government has clashed with Iran's judiciary over access to social media

Iran's judiciary has given the country's government 30 days to block a string of mobile messaging services, after they were used to publish "crimes" against "Islamic modesty and morals".

The move comes as a blow to Iran's president, Hassan Rouhani, who has so far taken a more liberal stance towards the use of social media in the country. "#Cyberspace should be seen as opportunity," he tweeted in May. And in August he surprised many by tweeting a picture of a female mathematician without a hijab.

His attitude is not shared by everyone in the country, however. Earlier this month 11 people were arrested for sending messages seen as insulting towards, Ayatollah Khomeini.

Local media reports said similar messages had also been sent about current officials in the Iranian government.

The messages appear to have been the final straw for Iran's hardline judiciary. On the weekend Gholam-Hossein Mohseni-Ejei - the first deputy of the judiciary - wrote an open letter to Mahmoud Vaezi - Iran's communications minister.

The letter named messaging apps Whatsapp, Viber and Tango as responsible for spreading the messages, and said "a one-month maximum has been provided… for closing and controlling information on the aforementioned social networks".

Mr Mohseni-Ejei wrote that the government's communications ministry had agreed to close the networks three months ago, but had so far refused to take action - hence the new 30 day ultimatum. If the messaging services are not censored within that time, the judiciary would "take the appropriate measures" itself, he wrote. The ministry responded to say it agreed illegal content should be removed, but that closing the networks altogether was another matter.

Iran has a history of monitoring and blocking social media. Youtube, Facebook, Twitter and Google Plus are all blocked in the country, but millions of people use proxy servers to bypass the restrictions.

Reporting by Sam Judah

You can follow BBC Trending on Twitter @BBCtrending

All our stories are at bbc.com/trending