Riyadh - Turki al-Hamad paid a heavy price for a tweet. Last year the novelist told his followers that Islam as practised in Saudi Arabia was not the "message of love" preached by the Prophet Muhammad. The outcome was six months in prison without trial.
Conditions were immeasurably better than when he was detained in the 1970s, but the hazards of speaking out in the digital age were still painfully clear.
Hamad's case was unusual though not unique. Like Hamza Kashgari, a journalist from Jeddah, he had provoked conservative religious zealots who oppose change in the kingdom – or provide the government with a handy excuse to do so. But Twitter is immensely popular and largely tolerated. According to recent research, Saudi Arabia has the world's highest Twitter and YouTube use per capita – a staggering 90m views of the latter a day. It also has the highest Facebook use in the Gulf.
On the face of it, it may seem surprising that an absolute monarchy with no parliament or political parties, tame newspapers and TV channels, enforced gender segregation and an official morality police should have such a flourishing social media world. But Saudis tweet in their millions to swap jokes, whinge about salaries, government waste and inefficiency – and corruption.
"Twitter has raised the ceiling of our freedoms," said Hamad. For Hatoon al-Fassi, an Islamic feminist who campaigns for womens' right to drive, social media has created a "virtual space" that compensates for Saudi Arabians' lack of legal freedom of assembly or association.
"Twitter helps us breathe," said the columnist Ahmed al-Najjar. Digital media have also blurred the boundaries between what is permissible and what is not – though criticising religion remains a clear red line.
Still, Saudi cyberspace is not only about politics – or exclusively for progressives. Conservative Islamist preachers such as Mohamad al-Arefe have millions of followers. And it was an "online incitement campaign" that put Hamad behind bars. Other clerics are infamous for promoting sectarian attacks on Alawites in Syria.
It is at home that the impact of social media has been most strongly felt. Last year, as spring fever swept through the Arab republics, Saudis were riveted by the appearance of a Twitter user named @mujtahidd (a diligent religious scholar), who tackled the taboo subject of corruption in the royal family. The state-appointed mufti then warned people off Twitter because it "promoted lies and rumours."
Mujtahidd, inevitably dubbed the "Saudi Julian Assange," has since run out of steam and scoops and now mostly retweets other peoples' posts. Exactly who he or she was or represented remains a mystery – though there was striking evidence of high-level inside knowledge and certainly a critical and reformist agenda.
On one view all this debate is nothing new. "We have always talked a lot in this country – and that includes discussing the royal family," argues Kamal, a businessman. "Now we use social media to do what we have always done. It just amplifies what we say."
Others see exciting possibilities. "You can meet like-minded people so maybe it will act as a seed – even for political parties," suggests a civil servant.
It is no secret that social media usage is monitored by the authorities, and as the mujtahidd case apparently shows, it can be reined in or silenced if deemed too subversive. Three lawyers are currently facing prosecution for tweets and retweets "deemed to undermine the judiciary".
In March, Muhammad al-Qahtani and Abdullah al-Hamid of the Saudi Civil and Political Rights Association were jailed for 10 and 11 years for offences including "internet crimes" because they used Twitter to promote their cause. Their lawyer, Abdullah al-Hussan, is convinced Twitter has helped ordinary Saudis better understand their rights.
Even senior royals and government ministers have Twitter accounts with hundreds of thousands of followers – Abdel Aziz Khoja, minister of information and culture, has 180,000. But that does not lead to transparency as ministries and subordinates hide behind fax numbers and impenetrable press releases. Officials admit openly that social media is a useful way of keeping track of public opinion.
"The Saudi government has a vested interest in keeping these things going," agrees the dissident, London-based Saudi academic Madawi al-Rasheed. "If you oppose a policy there is always a hashtag that allows people to vent their anger without actually doing anything. It's also a way of monitoring people to see who they are in touch with."
Recent examples include Twitter attacks on King Abdullah when he came out in open support of last summer's overthrow of President Mohamed Morsi by the Egyptian military – an affront to supporters of the Muslim Brotherhood. The crude hashtag "Olympic whores" generated furious debate over the unprecedented participation of Saudi women athletes in the 2012 London Games.
Twitter has been a vehicle for limited change – helping a campaign for female lawyers to be allowed to appear in court and forcing the "haya" (morality police) to behave less aggressively. Events that previously would not have been reported anywhere – protests in Buraidah and the Eastern Province – now appear first on Twitter.
"It's not just Twitter," said Hussan. "It's the Arab spring. But Twitter has been an important factor in encouraging reform in this country."
Unsuccessful attempts have been made to ban or control Facebook and Skype. And in an ominous-sounding move this month, a senior official of the state audiovisual commission suggested Saudi-made YouTube programmes might be regulated to ensure content "abides by our cultural and religious rules". His statement immediately went viral on Twitter.
Self-censorship plays an important role in the work of YouTube stars such as Fahad al-Butairi – known as "the Seinfeld of Saudi Arabia" – whose La Yekthar comedy series has 560,000 subscribers and 4.7m monthly views. Its spinoff Temsa7LY, featuring an engaging puppet alligator talking about videos and interviewing celebrities, claims 11m monthly views.
Saudis explain this phenomenal success by the dreary nature of the mainstream media and bland imported TV programmes – and by the sheer boredom of a society where 70% of the population is under 30, the majority have smartphones and where the religious police patrol public spaces while cinemas, bars and theatre are non-existent. "Twitter and YouTube replace the real world for many Saudis," says the educationalist Fawziah al-Bakr. "There are so many restrictions. They need these things to escape."
Stand-up comedy is growing rapidly — and not only in relatively liberal Jeddah: one popular new programme features a traditionally-robed woman, shown only in silhouette, who wisecracks in a rural Arabic dialect from remote Assir near the Yemeni border. Hisham al-Fageeh, another online hero, achieved global recognition with his brilliant (and all-male) "no woman no drive" video.
Behind closed doors some critics of the government like to paraphrase the words of the Palestinian poet Mahmoud Darwish to describe the effect of Saudi social media: yes, it does enlarge the prison cell; but no, it doesn't release the inmate.
Hamad, though, takes a longer view: "Saudi Arabia is in childbirth," he quipped. "A baby is coming. Is it a boy or a girl? We don't yet know. But this country is in labour. And in the end the new media will affect its political future."