“We are with the Islamic State and you are with Obama and the infidels,” Ahmed Abu Ghalous a big, angry-looking man in blue prison overalls, shouts after being sentenced to five years in jail for “promoting the views of a terrorist group” on the internet. The outburst earns him a further 50 dinar (£45) fine for contempt of court.

It is a sunny morning in Amman and the three uniformed judges in Jordan’s state security court are briskly working their way through a pile of slim grey folders on the bench before them. Each details the charges against 25 or so defendants accused of supporting the fighters of the Islamic State (Isis), now rampaging across Syria and Iraq under their sinister black banners and sending nervous jitters across the Arab world.

Thamer al-Khatib, convicted on the same charge, protests too: “Why is it all right for people to express sympathy for [Syrian president] Bashar al-Assad when he is killing women and children?”

His question goes unanswered but it resonates for Sunni Muslims far beyond Jordan as they watch western governments and their Arab allies mobilise to fight the jihadis while Assad gains the upper hand and Israel maintains its occupation over the Palestinians.

Security is tight inside and outside the building, guarded by a bewildering collection of soldiers, policemen and gendarmes. Relatives watch as prisoners in handcuffs and leg irons shuffle past. The no-smoking signs that flank the obligatory pictures of Hashemite monarchs past and present are ignored by court officials and black-gowned lawyers alike. Chants of “Allahu Akbar” can be heard from the holding cells. Like every other prisoner escorted into the narrow metal cage that serves as a dock, Khatib and Abu Ghalous wear the bushy beard of the devout Salafi.

In recent weeks these scenes have become routine as the kingdom has moved swiftly to crush the slightest sign of sympathy for or involvement with Isis and other extremist groups – especially Jabhat al-Nusra, the Syrian branch of al-Qaida. “We want to deprive these terrorist organisations of any ideological basis they have,” explains Mohammed al-Momani, the government spokesman.

“I’m dismayed by these cases,” says Musa Abdallat, a dishevelled lawyer who is representing 17 clients and repeatedly needles the chief judge. “They are difficult to defend and the court ignores the defence and imposes heavy punishments.”

Abu Bakr al-Baghdadi, self-proclaimed calpih of Islamic State. Photograph: AP

But many of the accused have confessed and pleaded guilty to using Facebook or the messaging app Whatsapp to praise Isis or pledge allegiance to its self-proclaimed caliph, Abu Bakr al-Baghdadi.

Jordan is one of the four Arab countries taking part in the US-led coalition against Isis but the only one that has borders with both Syria and Iraq. It was also the homeland of the notorious Abu Musab al-Zarqawi, the founder of al-Qaida in Iraq – a direct forerunner of Isis. The 2005 hotel bombings the group carried out in Amman, killing 60 people on what is often called “Jordan’s 9/11”, are a terrible reminder of the risks of homegrown fanaticism.

From King Abdullah II down, officials are blunt about their anti-Isis strategy. “We might run out of military targets,” says Momani, “but the security and ideological fronts will continue. We have a good grip on this phenomenon. These people don’t have a warm environment to flourish in.”

Leading Jordanian exponents of the Salafi-jihadi world view, such as Abu Muhammad al-Maqdisi, are now behind bars or silent, fearing arrest by the powerful mukhabarat secret police. Imams who are deemed extremist have been removed. A wider government information campaign echoes the king’s well-honed message about the values of moderate Islam and the rejection of the “takfiri” school that Isis uses to sanction the brutal and often sectarian killing of so-called apostates.

The damaged wedding hall at the Radisson SAS hotel in Amman after a suicide bomb attack in November 2005. Photograph: Hussein Malla/AP

Omar Othman, aka Abu Qatada, the radical preacher who was deported from Britain after prolonged legal wrangling and acquitted on terrorism charges by the state security court in September, has attacked Isis and condemned the beheadings of western journalists.

Arrests and prosecutions intensified after Isis captured Mosul in June, but the groundwork had been laid by an earlier amendment to Jordan’s anti-terrorism law. It is estimated that 2,000 Jordanians have fought and 250 of them have died in Syria – making them the third largest Arab contingent in Isis after Saudi Arabians and Tunisians.

The threat the most radical of them pose is evidently far greater at home than abroad: in one characteristically slick and chilling Isis video – entitled “a message to the Jordanian tyrant” – a smiling, long-haired young man in black pats the explosive belt round his waist as he burns his passport and his fellow fighters praise the memory of Zarqawi, who was killed in Iraq in 2006.

“The state is not really concerned about the export of terrorism,” argues a leading liberal intellectual. “It worries about people in Zarqa [a Jordanian city] making a homemade bomb.”

Radical cleric Abu Qatada at a court hearing in Amman in September 2014. Photograph: Jordan Pix/Getty

Statistics about support for Isis in Jordan are disputed, with the government accusing the media of exaggeration. Marwan Shehadeh, a researcher with a background in Salafi activism, estimates the group is backed by 8,000-10,000 people, but most of those only since the dramatic events in June, and they are not organised. “Jordan has made a mistake entering into an international coalition,” he argues. “The US put huge pressure on Jordan because they don’t want Isis to reach the borders of Israel.”

Muin Khoury, a professional pollster, has reached a similar conclusion about motives. “Isis sympathisers feel injustice and anger at America and Israel and always felt that Islam was under attack by Crusaders, and now they don’t agree with Jordan being involved in the coalition.”

Adnan Abu Odeh, a respected former minister, describes the government as “walking a tightrope”.

Ideology is certainly important but poverty and hopelessness may matter more, especially to the young. “You hear more and more stories of disaffected Jordanians going off to fight in Syria,” reports a western diplomat. “These are people with very little education, no job and nothing to lose, so whatever salary they get from Isis will be more than what they could get at home.”

Abu Musab al-Zarqawi, the Jordanian who founded al-Qaida in Iraq. Photograph: AP

Recently, in the Abdali area of Amman, street vendors taunted riot police with pro-Isis slogans when an unlicensed flea market was cleared by municipal officials. Jordanians gossip endlessly about Daesh – the pejorative Arabic name for the group.

“Why bother with the daily grind when you can go to Mosul, get paid $400 a month, get a wife – and live an Islamic way,” went an exchange between two men overheard by a fellow passenger in a taxi. Rumour has it that a woman whose husband died fighting with Isis now receives a generous widow’s pension from jihadi coffers.

Still, the crackdown has clearly had its effect. In the impoverished southern town of Maan, the black flags that flew defiantly in the summer have disappeared. In Hay Nazzal, a conservative area of Amman, slogans scrawled on the breezeblock walls say “death to Israel” or hail the resistance in Gaza, but there are none about Isis. A local Salafi suspected of terrorist sympathies was arrested recently by masked special forces personnel who stormed his home as snipers deployed on surrounding rooftops. Hundreds are said to have been detained across the country.

The district was also home to Jihad Ghaben, a young activist with the Hirak movement, whose street protests were an important element part of the brief Jordanian chapter of the Arab spring.

Last year he abandoned his studies to travel to Syria and join Jabhat al-Nusra. In his final Facebook posting before he was killed in Idlib, Ghaben warned the US that it would have to wade through “rivers of blood” and face the knives of Zarqawi and the airliners of Osama bin Laden. “Nothing had changed in Jordan,” sighs a friend, “so he and others went to look for another solution. Waging jihad was one of them.”

A fighter from the Islamist Syrian rebel group Jabhat al-Nusra seen through a smashed bus window in Aleppo. Photograph: Ahmed Jadallah/Reuters

Omar Khadr, 17, a Palestinian from Zarqa, went to Syria to fight Assad, not to build an Islamic state, insists his father, Zeid. After six months he returned disillusioned to Turkey and went voluntarily to the Jordanian embassy in Ankara. Refused all help there, he flew back to Amman where he was met by mukhabarat officers and is now serving a five-year prison sentence for membership of a terrorist group.

“This was a case of youthful enthusiasm,” says his father. “Omar followed the Syrian war closely on social media. Someone sent him pictures of Jabhat al-Nusra. I told the prosecutor in the state security court ‘if I was in your place I would pardon these people because you are turning them into supporters of Isis. It will only lead to more extremism’.”

The efficiency of the mukhabarat is not in question. Foreigners and Jordanians agree that there are high levels of trust in the state and its security agencies. Football fans watching Al-Faisaly Amman at a match chanted patriotic slogans urging the king to crush Isis.

“If I heard anyone talking about Daesh I would report them to the nearest police station,” volunteers a taxi driver who spent years in the army. The real fear is of a lone-wolf attack – thus the routine body searches and metal detectors at hotels and government buildings in the capital.

Of course security is important, says Abu Odeh, a powerful figure under King Hussein and, now, in his 80s, a liberal voice who emphasises the need for real political and economic reform in Jordan. It’s an important point at a time when the preoccupation with terrorism has all but silenced talk of the changes some hoped would come in the early, hopeful phase of the Arab spring. “Even if you defeat Isis in the field you will not destroy them,” he argues.

“To kill the idea you need real reform in the Arab world. Isis has helped those who are not sincere about reform to find an excuse. The irony is that the excuse perpetuates the reasons that Isis came to exist in the first place.”

• This article was amended on 1 December 2014 to correct a misspelling of takfiri.