Image copyright AFP/Getty Image caption Maulana Masood Azhar founded JeM in 1999 - and is in "protective custody"

Standing guard at the gate of a madrassa on the outskirts of Islamabad was a stern-looking young man, armed with what appeared to be a powerful automatic rifle, and missing one eye.

Inside, one of those involved in running the religious school acknowledged it is "said to be run by Jaish-e-Mohammad" - the militant group which claimed responsibility for last month's suicide attack in Indian-administered Kashmir's Pulwama district which killed some 40 troops and sparked a conflict between Pakistan and India.

But the cleric said the allegations were untrue and the madrassa was, in fact, just another ordinary Islamic school.

A small poster on the wall behind him, however, depicted an assortment of guns alongside a slogan evoking a famous battle from Islamic history. In the dusty street outside, a poster advertising a rally on behalf of the Kashmiri cause was emblazoned with the distinctive white and black flag of Jaish-e-Mohammad (JeM).

As part of a "crackdown" on militants in Pakistan, hundreds of seminaries and other buildings allegedly linked to groups, including JeM, have been taken over by the government in recent days.

The brother of JeM founder Masood Azhar has been taken into "preventative detention" alongside another relative and dozens of others. No-one from the security forces had contacted this madrassa in Islamabad however. Azhar himself is believed have been in protective custody in Pakistan since 2016 - though he has continued to release audio messages to supporters.

"It is our resolve that our soil will not be used to harm anyone else," Pakistan's Interior Minister Shehryar Khan Afridi told reporters earlier this week, stressing that the action was not due to any "external pressure" but had already been planned by the authorities.

But there have been other highly publicised crackdowns on such groups before too, often when Pakistan has been in the international spotlight, only for the mosques and religious schools to be handed back to their previous owners, and those detained to be later released due a "lack of evidence."

Image copyright Reuters Image caption The suicide attack in Pulwama was the single deadliest attack in Indian-controlled Kashmir since the insurgency began

As a result some are sceptical that this latest action really means the Pakistani state will put an end to the activities of India-focused militant groups, long believed to have enjoyed the support of the country's intelligence services. Indian officials told the BBC they had "seen all of this before".

Jaish-e-Mohammad was founded by Masood Azhar in 2000, shortly after he was released from prison in India following the hijacking of an Indian airline by fellow militants.

Azhar had been an influential militant figure in the 1990s with links to the conflicts in both Afghanistan and Kashmir.

Pakistani analyst Ahmed Rashid says in those early days JeM jihadists were "highly trained and highly motivated" fighters. And because they were not overtly linked to the Pakistani state, India had "no clear answer" on how to respond to their attacks. Pakistan retained an element of plausible deniability.

Another militant group focused on Kashmir, Lashkar-e-Taiba (LeT), is also believed to have enjoyed the patronage of the security services.

With the international community increasingly focused on the threats from jihadist groups after the 9/11 attacks, Pakistan banned both JeM and LeT. However, their leadership has never been convicted of any crime, and both organisations took on new names, with Lashkar-e-Taiba becoming Jamaat-ud-Dawa (though they claim they are separate.)

In 2007, the Pakistani state's uneasy relationship with jihadist groups was finally shattered by a bloody standoff between militant supporters and the security forces in Islamabad.

After that, jihadists grouped themselves into either "anti" or "pro" Pakistan camps. The former targeted Pakistani security forces and civilians, killing thousands. The latter remained focused on fighting American forces in Afghanistan, and Indian forces in Indian-administered Kashmir.

The leaders of Jamaat-ud-Dawa, and Jaish-e-Mohammad remained loyal to the Pakistani state, although many of their fighters, particularly from JeM, defected to anti-state groups.

One senior commander with the Pakistani Taliban, which has been fighting against the Pakistani army, told the BBC that many JeM members joined their "jihad" against the government. Although many later changed their minds, he said, there remain a number of former JeM militants within the organisation and other groups such as al-Qaeda.

Image copyright Planet Labs Inc./Handout via Reuters Image caption Satellite images have raised questions over India's claim to have demolished JeM training camps in Pakistan

Pakistan's security forces have been remarkably successful in reducing the capabilities of anti-state militants. The number of those killed in terrorist attacks in Pakistan dropped from close to 2,500 in 2013, to 595 in 2018 according to the Pakistan Institute for Peace Studies.

However, that leaves the question of what to do with the more loyal groups such as JeM and LeT/JuD, who are alleged to have continued to launch attacks on India.

JeM is believed to have carried out two major attacks in Indian-administered Kashmir in 2016, while Lashkar-e-Taiba founder Hafiz Saeed has been accused by Indian authorities of orchestrating the 2008 Mumbai attacks - though he denies that.

Media playback is unsupported on your device Media caption Hafiz Saeed tells the BBC that Washington is unfairly targeting him

At the time it was alleged the Pakistani intelligence services were complicit, and although they denied that, legal action against those suspected of involvement has been suspiciously slow.

But now the activities of these militant groups seem to be an obstacle to Prime Minister Imran Khan's stated aim of improving the country's relationship with India; and perhaps more crucially they have also contributed to Pakistan being placed on the Financial Action Task Force "grey list" for not doing enough to tackle the financing of militant organisations.

A "grey list" designation can make international businesses think twice before conducting business in a country, and Pakistan's economy is in need of foreign investment.

Pakistani officials, however, have expressed concern that directly confronting JeM or JuD could provoke another spike in violence.

Last year, analysts and Pakistani military figures floated the idea of "mainstreaming" some of those linked to militant groups.

Shortly afterwards, ahead of the elections that Imran Khan won, supporters of JuD (and LeT) founder Saeed created a political party. Although they were unable to win a single seat, they may still prove easier to deal with than JeM.

Media playback is unsupported on your device Media caption Kashmiris from both sides told the BBC about their disrupted lives during shelling in the region

Over the years Saeed has managed to establish a large charity network of ambulances and basic healthcare facilities. Many of them are now being taken over by the government, but analyst Amir Rana from the Pakistan Institute for Peace Studies says the authorities have "very little concerns about retaliation" from his supporters. JuD have signalled they will challenge the moves in court.

By contrast, Mr Rana told the BBC, officials are worried about the potential of violence from the more secretive JeM - the group responsible for the Kashmir attack. After JeM was banned in 2002, splinter elements of the group tried to assassinate the country's then military ruler Pervez Musharraf.

At a recent closed meeting between the head of the Pakistani Army and a group of politicians, a source told the BBC that military leaders gave assurances that the militants would be tackled. However the military officials warned there were too many to completely eliminate by force alone, and instead suggested some be mainstreamed.

Early proposals by the government reportedly include establishing de-radicalisation centres for members of these groups, and finding them jobs, including somewhat bizarrely using them as a kind of "paramilitary" force.

A senior politician told the BBC that there was now an understanding in Pakistan that the use of "proxy" forces in Kashmir is counter productive, distracting from allegations of Indian "human rights abuses". But, he added, the preference would be to engage with militants peacefully if possible.

The latest takeovers of madrassas and mosques linked to militants will give the Pakistani government some favourable headlines, but it's what they do next that will count. Will there be actual prosecutions? Will the groups really be prevented from carrying out activities across the border? Are attempts at "mainstreaming" really aimed at weaning jihadists away from violence? Or are they simply a way to give them a veil of legitimacy?

I visited another madrassa, in another poor Islamabad suburb, that was taken over last year by the government from Hafiz Saeed's charity, JuD.

The staff in charge there remains the same. They tell me the only change is that a local government official carries out regular inspections, and that they are now funded by the government rather than by donations.

The traditional shalwar kameez garment worn by the security guard at the madrassa is even still embroidered with the now officially banned group's name: JuD.