Alarmed by how jihadi veterans back home from Afghanistan and Iraq joined an al Qaeda uprising a decade ago, Riyadh is now trying to halt recruitment of Saudis to the Islamic State militant cause, even as it funds and arms rebels in Syria.
The government and clerics are pushing their message in both the media and the mosque: Saudis who join radical groups such as Islamic State will get sucked into a jihadist experience that is ugly and futile.
Local media have highlighted the case of Fahd al-Zaidi, a Saudi who said he was duped into joining a war against fellow Sunni Muslims instead of fighting for their freedom.
"Anyone who dared to question the Islamic State would be put in isolation and prevented from contacting others," he said in comments reported in the local Arab News and carried widely by other Saudi media. "We spent days and nights wondering how we allowed ourselves to be fooled by a bunch of conmen."
With the largely Sunni rebel groups often fighting each other rather than Assad's forces, Riyadh believes the Syrian war should be left to Syrians. Those Saudis who shift their allegiance from the ruling Al Saud family to Islamic State's caliphate, which it is fighting to establish across Syria and Iraq, represent a threat to the government of the U.S. ally.
Informed by its previous experience, the kingdom is using an array of tools against jihadi recruitment apart from the media.
A royal decree in February ordered long jail terms for people who went to fight overseas or helped others do so, or for those giving moral or material aid to groups including Islamic State and al Qaeda's official offshoot in Syria, the Nusra Front. Several people have already been convicted.
Top clerics including the Grand Mufti and members of the Senior Council of Scholars, the highest religious bodies in the kingdom, have repeatedly denounced militant groups in sermons and fatwas. While some senior government-appointed clerics have described the Syrian war as a jihad, they have made clear it is one that should be fought by Syrians, not by Saudis.
Nevertheless, thousands of young men appear to have slipped through the net and joined Islamic State and other groups. The authorities say they are aware of 2,500 Saudis fighting overseas, but admit there may be more.
Unlike in previous conflicts before militants learnt to use social media networks as recruitment tools, would-be jihadis no longer need extensive contact with facilitators inside Saudi Arabia. Some have simply flown to Turkey and headed for the Syrian or Iraqi border. Others used online contacts to get a mobile phone number for somebody who would help them once they arrived.
Salman, whose brother followed the route via Turkey to fight alongside Islamic State and Nusra Front in Syria, said his sibling had been recruited online. But the brother, who is now on a government deradicalisation program, found the promises of a pure jihad did not match a far messier reality.
"His situation was very bad. He saw a lot of blood... there was a very big change in him when he came back. He blamed himself very much," Salman said in a phone interview arranged by a psychologist working with the program and conducted on condition of anonymity.
Based in a secure facility in Riyadh, the program uses clerics to argue against militancy, and provides art and sports classes where psychologists monitor inmates' behavior.
It encourages family visits and has helped inmates - or "beneficiaries" as the authorities call them - to find jobs and even marriage partners to help reintegrate them into society. It has a recidivism rate of around one in 10, officials say.
Saudis went to previous jihadist wars mostly out of a sense of international Muslim solidarity which the authorities had fostered for decades as a counterweight to secular anti-monarchist ideology, say analysts.
In the 1980s it was the government and ruling family which encouraged Saudis to join the fight against Soviet forces occupying Afghanistan. But many clergy, particularly at a local level, were involved in recruitment.
The kingdom's strict Wahhabi school of Islam, with its message of intolerance of Shi'ites and non-Muslims, may also have made Saudis more open to militant thinking.
The U.S.-led invasion of Iraq, which deposed the Sunni leadership of Saddam Hussein in 2003 and brought a Shi'ite-led government to power, deepened a belief among many young Sunnis, including Saudis, that their branch of Islam faced persecution.
"I saw on the television news that my brother Muslims needed help, so I thought I'd go and join them," said Ayad al-Onazi, who spent four years fighting alongside Iraqi insurgents before his group fell apart after a battle with al Qaeda.
When he told his family he had arrived in Iraq in 2005, they begged him to return but, sure he was doing the right thing, he stayed until 2009.
Today, Islamic State is countering pressure on its fighters to come home. In a recent video, it showed a young man identified as Abu Hajr al-Jazrawi who was about to become a suicide bomber. Jazrawi tried to tell his parents that they were wrong to want him back.
"O my mother and father, as long as you say to return, to leave this path and not be deceived by Islamic State, and not to be deluded by the Caliphate, I will only repeat the words of he who said: 'would that my people knew!'," he said in the video, translated by SITE Monitoring.
Not all Saudi families have been upset to see loved ones risk death. Some publicly celebrated their sons' "martyrdom" a decade ago, said Thomas Hegghammer, author of the book Jihad in Saudi Arabia and a research fellow at the Norwegian Defense Research Establishment. "Their friends would post phone numbers for people to call and congratulate," he said.
Such displays no longer occur, but it is unclear whether this is because public attitudes have changed or Saudis are simply frightened of the security services. Nevertheless, the government campaign has clearly driven much of the recruitment effort further underground, making it harder to assess who is going to Syria and Iraq and why.
"There's so much less visibility now into the jihadi community. They don't write as much about themselves as they used to. Activists in Saudi Arabia are more restrained now online than they used to be," said Hegghammer.
FAMILY PUSH BACK
In August people in the small desert town of Tumair, about 160 km (100 miles) north of Riyadh, tipped off the authorities that two mosque imams were recruiting jihadis.
The clerics, identified in local media as Ali al-Salloum and Hamad al-Rais, were detained with six others in Tumair on suspicion of working to send people to Islamic State, the Interior Ministry later said without confirming their names.
This showed both how local religious networks can still pose a threat, and how Saudi society is growing less tolerant of such efforts. But in a sign of how sensitive such subjects are, no Tumair residents contacted by Reuters would discuss the case.
Ali al-Afnan, the psychologist working with the deradicalisation program, said family ties were at the center of its strategy to stop people going to war or entice back those who had already done so.
What authorities now fear most, he said, is the ease with which militants can use YouTube and Twitter to encourage young men to go to Syria or Iraq. This is a problem they share with other Arab governments, as well as Western countries which are also trying to discourage their citizens from joining jihad.
Riyadh has helped mothers of fighters in Syria to share their pain on television. In February a woman who called herself "Umm Mohammed" or "mother of Mohammed" appeared on a popular television to castigate firebrand preachers for luring her 17-year-old son to Syria.
The show's host, Dawood Al Shirian, told Reuters that the government had been very receptive to his efforts to speak to such people and the son, Misfer, had eventually returned home after seeing his mother's appeal.
Misfer later appeared on the program himself and said on it that he had decided to join the jihad after listening to sermons online by an influential Syrian preacher, the Saudi-controlled al-Arabiya news channel reported at the time.
He traveled to Turkey alone and paid a smuggler to help him cross the border, but he grew disillusioned because some of the rebels in his group drank alcohol, he said. (editing by David Stamp)