Shabhaz Ahmed has a story to tell. It is an old story, one told by many men at many different times. It is about going to war, training, fighting in a foreign land, watching friends die and finally returning home, disillusioned by defeat.

In the case of Ahmed, however, home is a village in the eastern Pakistani province of Punjab, the foreign land is Afghanistan, the training was provided by the Taliban, the enemy was the US and their local auxiliaries, and the hardships involved a lengthy period of imprisonment in appalling conditions.

Ahmed is one of several hundred Islamic militants living in the Punjab who have been enrolled in a new "deradicalisation programme" by local police. The scheme aims to ensure they do not return to extremism. The Pakistani army runs another centre, in the Swat valley near the country's western frontier, where former militants from insurgent groups spend weeks on a scheme that also tries to reverse what military and police officials call the process of "brainwashing".

Such programmes were once extremely popular. In the 10 years following the 9/11 attacks of 2001, similar schemes were set up in almost every country where extremism became a problem, from the Far East to Europe. Some were lavishly funded, others poorly resourced. Based on classic criminal rehabilitation programmes, most involve a mix of vocational training and counselling, with a religious component designed to challenge the "single narrative" of Islamic extremism. They have been lauded by policymakers, counterterrorist experts and pundits as a critical part of the campaign to defend state and societies against militancy. The problem, however, is that nobody knows if they actually work.

The Punjab police programme, though perhaps among the least well-funded, is typical of many. Ahmed, now 31, was one of thousands of young Pakistanis who went to fight US troops in Afghanistan in the autumn of 2001 and found themselves trapped by the rapid collapse of the Taliban regime. He had no previous involvement with extremism, he says, but volunteered with a group of friends from Karachi shortly after the 9/11 attacks. Inducted into a Pakistani militant group, he found himself deployed in the north of Afghanistan when US bombers, guided by CIA teams, dumped huge amounts of explosives on Taliban frontlines.

Interviewed in a police safe house in Lahore, he is vague about whether he actually fired a shot in anger. He does however remember how, shortly after being captured by US auxiliaries near the northern city of Kunduz, he saw friends packed into steel shipping containers. Only a quarter of them survived the trip to the makeshift prison where he was held for more than two years. More died there. Eventually, Ahmed was transferred to a prison near Kabul and then back to Pakistan, where he spent another 15 months incarcerated in appalling conditions. He was finally freed after his parents and a local cleric vouched for his good behaviour. Ahmed got married, had children and set up a small shop: "It's not much, but I get by," he says.

Learning a trade ... former militants study electronics at the Swat valley centre. Photograph: Mian Kursheed/Reuters

For obvious reasons, most of the deradicalisation programmes work with currently or recently detained militants. These, according to Professor Hamed El-Said, an expert in deradicalisation at the Manchester Metropolitan University, are a useful source of information, but not necessarily central to any ongoing threat. On the whole, no attempt is made to deradicalise the most committed extremists, particularly those with links to al-Qaida or who were involved in serious plots, successful or otherwise.

Why then, do Punjab police still consider men like Ahmed dangerous? The answer, police officials explain, lies in the nature of the extremism they are fighting. There have been hundreds of terrorist attacks in the province in recent years, including some of the most spectacular ever in Pakistan. Militants attacked the Sri Lankan cricket team on the way to a match in Lahore in 2009. Police facilities have been besieged.

Though there have been fewer major strikes in or around the city recently, danger remains, with "hundreds" of militants poised to move. "We are not sure why it is quiet. They seem to be waiting for something," said one senior Punjabi police officer in December. "There are lots of plans being foiled here. And lots of intelligence reports of planned operations that are called off because the militants know we are aware of them. But the capacity remains."

That capacity depends in part on people such as Ahmed, argues Mushtaq Sukhera, head of the Punjab counterterrorist police and the man behind the deradicalisation programme: "He's an ex-militant. The organisations turn to people like him for help with reconnaissance, with storing equipment, for safe houses, for transport. Without that kind of help they can't operate. It's a pattern we see again and again: people provide help on the basis of old relationships. That's why he is potentially dangerous."

In the Punjab almost all veterans – particularly those who fought in Afghanistan – are known to local security services. The scheme there began early last year with a batch of 300 former militants, most with similar profiles to Ahmed. It has since been rolled out across the province, from Lahore and surrounding districts where law and order is strongest, to the rougher regions in the south, where militant groups with strong links to the military-dominated security establishment are well entrenched.

Sukhera's staff, based at the new headquarters of the Punjab's counterterrorist police, approached some 5,000 possible candidates, mainly aged 18 to 40 and unemployed, semi-employed or unskilled. Those who accepted received three months of paid tuition in a craft such as plumbing, carpentry or electrics, followed by an interest-free loan to set up a small business. The aim was to counter any financial offers the extremists might make in coming years.

Former al-Qaida members play volleyball at a camp in Riyadh. Photograph: AFP

The "students" also had lengthy sessions with religious scholars in the Deobandi tradition, the conservative strand of Islam followed by the Afghan Taliban and some Pakistani militants. The discussions covered misconceptions about Islam, attitudes to non-believers and less rigorous Muslims, the concept of "holy war" and attitudes to the Pakistani state: "It is a comprehensive approach," says Sukhera.

One of the first regimes to look at deradicalisation was the Egyptian government of Hosni Mubarak. After initial reluctance, Mubarak's intelligence services moved to exploit divisions between hardliners and relative moderates in the Gamaa Islamiya group, which had waged a decades-long campaign of violence to establish an Islamic state. The intelligence aim was "collective deradicalisation", by which an entire group is prised away from militancy, and provided a model for later efforts.

After the 9/11 attacks, Yemen and Singapore led the way. The Yemeni scheme took the form of ad hoc outreach through interlocutors including tribal chiefs and Islamic judges. Poorly resourced and poorly thought out, it was as much aimed at deflecting US pressure from the government of President Saleh as fighting militancy. "There was no follow-up and al-Qaida were offering $300 a month as a salary. A lot of these guys had families to support, so they just went back,'" says El-Said. Indonesia, also under pressure from Washington but unwilling to take harsher measures, launched a programme around the same time.

The Singapore scheme, well resourced and with serious political intent behind it, seemed to indicate the way forward, and a predictably well-financed Saudi scheme was set up in 2004 when the kingdom was hit by a wave of extremist violence involving both hardened veterans of the militant training camps in Afghanistan and locally recruited men. The scheme was then expanded to deal with young men who set out to fight in Iraq and returnees from the Guantánamo Bay prison camp. Eager to show their will to fight violent extremism, Saudi authorities went to some lengths to publicise their deradicalisation efforts, hosting conferences attended by intelligence services from around the world and leaders such as Gordon Brown who controversially shook the hands of a pair of "reformed militants" while in Riyadh. American forces imported techniques from Saudi Arabia into Iraq when they started working with the vast population of detainees in 2007–08; tactics learned there were imported to US-run detention centres in Afghanistan.

By the end of the last decade, as the numbers of incarcerated militants grew and as understanding deepened in Europe, the UK and the US of such populations' vulnerability to extremism, further schemes were set up. A major EU-funded conference was held on deradicalisation in Denmark last year. Overall, there are now thousands of militants around the world in schemes with funding running into probably billions of pounds.

An attendee has counselling at the Swat valley deradicalisation centre. Photograph: Farooq Naeem/AFP/Getty Images

More recently, however, some people are starting to ask tough questions about quite how effective such schemes are, and whether they could be providing governments with an excuse to avoid actually dealing with the causes underlying the militancy.

"Around 2009 to 2010, this was very fashionable. It really looked like the answer. Now it is looking like a bit of a fad," says Professor Peter Neumann of the international centre for the study of radicalisation (ICSR) at King's College, London. He oversaw a team that in 2010 produced a comprehensive study of 15 prison-based "deradicalisation" schemes.

Those running the schemes inevitably laud their achievements. Ministry of Interior officials in Riyadh say recidivism rates for their scheme are 10% to 20%, considerably lower than those for "normal crimes". The Indonesians claim that, of around 200 militants deradicalised, only about 10% have gone back to extremist activities. The US sees the effort with Iraqi detainees as a success, though it is clear the Afghan scheme has been a major disappointment. Sukhera says none of those involved with his scheme in the Punjab have reoffended and hopes to get funding for more than 1,300 militants to participate in the programme.

Recent research questions such claims, however. Both the King's College report and a comprehensive study by the Rand Corporation published in 2010 point out that recidivism rates are neither the best metrics to judge success nor particularly reliable. The Saudi scheme, despite its apparent overall efficacy, has seen several high-profile failures. (Two key members of al-Qaida in the Arabian Peninsula underwent the programme on release from Guantánamo, but then returned to militancy.) Of several hundred militants detained in Indonesia since the October 2002 Bali bombing, only 20 could be considered reformed and are actively working with police. At least 20 recidivists were involved in the terrorist network uncovered in Aceh in north-western Indonesia in March 2010, including some who had previously been arrested for ordinary crimes, such as drugs and, in one case, murder, the Rand report notes. Equally, success in many places, such as Singapore, may be as much to do with 24/7 surveillance of the released militants as anything else, experts say. In the Punjab, the former militants are all known to police and intelligence services and are often have to check in regularly with the authorities.

Another worry is the nature of the supposed deradicalisation. In Saudi Arabia, clerics told veterans returning from fighting US troops in Iraq in the last decade that it was not their desire to fight the unbelievers that was the problem, but their departure for war without the consent of their sovereign. This crucial theological distinction was often lost on visiting western politicians. In Indonesia, the argument from local clerics was similar: "local jihad" was unjustifiable, whereas global jihad against "the far enemy", ie the west, was legitimate, given certain conditions.

"The cultural context is very important," says Philip Mudd, who spent 25 years at the CIA working on South Asia and terrorism. "The bunch of kids who want to fight in, say, Iraq have substantial sympathy." This is the key issue. Deradicalisation does not take place in a vacuum. One of the reasons for the disappointment of the ongoing US-led detainee deradicalisation programme in Afghanistan is that, when released, its subjects return directly to villages in areas where support for the Taliban insurgents is strong. "Even if you are convinced by what you have heard during the programme, you have to be a very brave man to go back to your community and start saying that everyone else is wrong," says Neumann.

Critically, Neumann's team found that deradicalisation could only work when an insurgency or an extremist movement was losing. He cites the programmes in Saudi Arabia, now almost entirely free of extremist violence, and Iraq – where Sunni militant detainees had effectively recognised they had been defeated in their multiple conflicts with the US occuppying forces and the Shia population – as examples. "Deradicalisation, done well, can be extremely effective given certain conditions. But where there is an ongoing civil war, such as in Afghanistan, it is much more difficult, even impossible."

In Pakistan, where there is massive ongoing civil conflict too there is an additional complication. Many of the ex-militants on the Punjab programme belong to groups such as Lashkar-e-Taiba or sectarian outfits that have received support from the Pakistani security establishment for decades because paramilitary groups are seen as a weapon that will offset India's evident demographic and conventional military superiority. Surveys reveal that, though those who target the Pakistani state are increasingly reviled, groups suposedly dedicated to a more international agenda or who are involved in broader social activism have retained a positive image among many Pakistanis despite the increasing violence associated with extremism, and remain deeply embedded in some communities. "We picked up a man from one village who gave us the name of literally hundreds of men in the district where he lived who were involved one way or another," one senior officer remembers.

Sukhera, however, is a believer. Last year he spoke at length with Malik Ishaq, leader of the anti-Shia terrorist group Lashkar-e-Jhangvi and one of the most violent extremists in Pakistan. The 53-year-old militant was in Kot Lakhpat prison in Lahore with 44 cases of terrorism and murder involving at least 70 deaths registered against him.

"We had many sessions with him and spoke to him about his narrative. We defeated his logic, his rationality. We told him that this country had been created in the name of Islam and if you keep fighting, the poor of this country are the ultimate sufferers," Sukhera says. "Eventually he agreed."

The winning argument, the policeman says, was that even in Saudi Arabia the Shia are living in peace. "There is no fatwa against them from the Saudi clerics, so why are you killing them here, I said. We had long arguments. Ishaq is now on the right path."

Ishaq may have been less convinced than he looked. Last July he was released; there was no evidence to hold him any longer, a court decided. The number of attacks on Shia rose dramatically and in February, five days after a bombing in Pakistan killed almost 100 Shias and amid national outrage, Ishaq was jailed again.

And though Shabhaz Ahmed now says he is happily married and committed to making a success of his new electronics shop, he still turns his experiences in Afghanistan over in his mind. "I had never seen poverty like I saw in Afghanistan and I suppose it's true that with the US there and everything, there are more jobs for the Afghans," he admits. "And I never really thought that the US was against Muslims."

But many things still trouble him. He thinks, sometimes, about the problems in his own country – though he insists any effort to overcome them has to be peaceful. He remembers the men who travelled with him and the container trucks full of corpses he saw in northern Afghanistan. He, like so many Pakistanis, subscribes to conspiracy theories about the 9/11 attacks.

"What then is the reason that the [US] came so far from home, all this way to fight? Even now I don't believe the attack on the World Trade Centre was the work of the mujahideen. It's not possible. So who did it? I don't know. I remember what I was told, how a good Muslim believes that if you kill one innocent person you kill the whole of humanity. I am sure that is right. But also that one should strive to do good and protect the weak from tyrants. I am sure that is right too. So in the end all I can say is, I don't know."

• This article was amended on 12 June 2013. An earlier version said the Sri Lankan cricket team was attacked on the pitch during a match in Lahore in 2009. The attack took place while the team was on the way to a match.