Image copyright Thinkstock

It's become known as the Aarhus Model, a programme designed in Denmark's second city to dissuade young people from going to fight for al-Qaeda or Islamic State. Thirty travelled to Syria in 2013 but only two so far this year - and only one in 2014. Ahmed is one young man who was convinced, a few years ago, to draw back from the first step on a path that could have ended in jihad.

We meet in a large, loud, busy Turkish restaurant on the edge of the city, but we don't stay long. There are two of them - we'll call them Ahmed and Mahmoud - and what we have to talk about demands a measure of privacy. Mahmoud drives us to a large hotel, where we sit down in a quiet room.

Ahmed is 25, he says, born in Somalia, although he's lived in Denmark since he was six.

Ahmed then tells his story, describing an unexceptional childhood - he was a "normal kid" growing up in the Aarhus suburbs, who liked playing football, doing well in school, learning Danish fast. "Everything was good for me at that time," he says.

Then, when he was in his teens, his father announced that he was taking him on the Hajj, the pilgrimage to Mecca.

They call me a terrorist? I will give them a terrorist if they want that

"It was important for my father to get me more religious," he says.

"I didn't know much about my religion. It was like I had left it in Somalia. But my father said, you are a Muslim, you have a Muslim name. You have to know your history, your background and your religion."

So the family went to Mecca and Ahmed remembered returning to Denmark with a sense of relief.

"When we came back I was happy and I was a new person with a religious identity. I saw the world differently. I saw that it was important for a person to have a connection with his god, I saw that there was an afterlife."

But Ahmed's new faith got him into trouble at school. He abandoned jeans and T-shirts and took to wearing traditional Islamic dress. He became defensive and argumentative when the subject of religion came up. He acknowledges today that he could have handled things better, but at the time, he said, he responded aggressively because he felt he had a duty to defend his religion when he was being baited by his Danish classmates.

Image copyright AFP Image caption The suburbs of Aarhus include some of Denmark's poorest neighbourhoods

"They would say things like, 'You stone your women, you lash people who speak freely,' and I felt I had to defend my religion, but I didn't know how to debate properly and it went out not correctly."

Ahmed was shortly to discover exactly how "not correctly" it had come out.

He was out one evening when his father rang. "Where are you?" he demanded. "What have you done?" His father said the police had just knocked on the door and were looking for him.

"When I got home, he was shocked and angry. He told me that I had to go straight to the police station the following morning, and ask them what they wanted."

So Ahmed went to see the police and was amazed to discover that he'd been turned in by the principal of the school.

Find out more

Listen to Tim Mansel's radio documentary Returning Jihadis - A Danish Solution? for Assignment on the BBC World Service. Click here for transmission times, or to listen via the BBC iPlayer.

"The reason you are here," he was told, "is that your classmates are afraid, they think you are extremist and that you are capable of dangerous things. They think you have been radicalised in Saudi Arabia."

Ahmed grins as he remembers all this. But it wasn't funny at the time - he had a vision of being put on the next flight to Guantanamo. "I was shocked," he says "and I had no words to defend myself."

The police then told him they would need to search his home and that they would need the password to his email account and any other social media that he used.

"I gave them everything and they searched my house and it was very humiliating to watch. When they left I was shocked and I was angry," he says.

Image copyright AFP

It got worse. All this had happened during the last week of school, and he had missed the end of year exams. The school, he told me, refused to allow him to sit them late.

"That gave me a punch in the face, and gave me the feeling this society is total racist," he says. "They call me a terrorist? I will give them a terrorist if they want that."

Ahmed smiles again as he recounts the story. It sounds foolish all these years later.

Ahmed then told everything to his friends at the mosque. They were sympathetic, he says, and invited him home. There were long discussions about the hypocrisy of the West in its dealings with Muslims and Muslim countries. They watched a lot of jihadi videos online. Ahmed remembers in particular those that featured Anwar al-Awlaki, the radical American cleric of Yemeni descent, who was killed in a drone strike in 2011.

"He would say things like, 'We are at war with the West, the West will kill all the Muslims around the world if we don't stand up to them,' and I was like, OK, and my friends were saying, 'Yeah, he's totally right.'"

Finally someone drew Ahmed aside and suggested that if he wanted to learn more about Islam and be respected as a Muslim, he should go to Pakistan. "He told me about a school there, where they have good teachers and where they teach Islam in the best way."

European militants who have gone to Syria/Iraq (estimates) Country Per 1m inhabitants Total Belgium 40 440 Denmark 27 100-150 Sweden 19 150-180 France 18 1200 Austria 17 100-150 Netherlands 14.5 200-250 Finland 13 50-70 Norway 12 60 UK 9.5 500-600 Germany 7.5 500-600 Source: ICSR (Jan 2015)

Ahmed says he told his father what he was planning. His father said he wouldn't try to stop him but advised him to finish high school first. Then the telephone rang.

It was the police and they wanted to invite Ahmed out for a cup of coffee.

He went, reluctantly.

"Something inside me said these people are never going to leave you alone, so why don't you see them face-to-face and just say your opinion. So I went to the meeting and they gave me some coffee and we talked and I was angry and I said, 'You know what, I'm going to Pakistan. It's not illegal. I can do what I want. When I get the money, when I've finished high school, that's where I'm going. Sayonara. See you later.'"

But the police had an offer. They wanted him to meet someone, another Muslim, they said, who could talk to him about his feelings and his anger in a way that they, the police could not.

Ahmed smiles again as he remembers his indignant reaction. What kind of Muslim could this be? Clearly a traitor.

This is how he met Mahmoud. And this is how he was introduced to what the world has now come to call the Aarhus Model.

The Aarhus Model

The model involves both prevention and cure. In some cases it offers young people returning from Syria the opportunity to reintegrate into Danish society, provided they've committed no offence abroad. In others, it provides mentoring for those intent on going to Syria, to persuade them not to travel.

Efforts to prevent radicalisation have been running since 2007. Preparations for dealing with events in Syria started in mid-2013.

An extensive network including parents, social workers, teachers, youth club workers, outreach workers and the police may raise the alarm about a young person who is being radicalised.

Individual counselling is provided for people who intend to travel to Syria, and in some cases a mentor is assigned. Parents of these people take part in self-help groups.

Ahmed says it took several months for him to relax. In the beginning he would frisk Mahmoud every time they met, because he wanted to check he wasn't wearing a microphone. He says their arguments were intense and he was frustrated that Mahmoud seemed to have a quiet, logical answer to everything. Ahmed says he asked his friends at the mosque for help, for arguments to defeat this "traitor who's working with the police".

"But then I started to take my hands down - you know in boxing you have your fists up high - and I said I have to listen to this guy, this guy never gives up.

"And he discussed with me in a logical way, in a way that I could understand that where I was going actually was dangerous.

"Mahmoud said, 'Yes, you were treated wrong, that's correct, but what you are doing is you are ruining your own life if you go to Pakistan.'"

This, said Ahmed, made sense to him. He wasn't being told that he couldn't be a Muslim. He was being told simply to be a good Muslim who doesn't hurt innocent people.

"You can still be a Muslim and have a prosperous future in Denmark. You can be an asset to society, not a liability," he remembers Mahmoud telling him.

Mahmoud is listening and nodding.

"Actually Ahmed has told me that a lot of times, that if we hadn't had those conversations, he thinks that he would be in Pakistan now," he says.

Ahmed graduated from high school and instead of going to Pakistan he went to university. He is about to graduate. He has also got married.

"I'm happy right now. I see my future in Denmark. I couldn't see that before because it was all dark," he says.

"And now that I'm actually finished with the programme. I hope that personally I'm going to be a mentor some day and help other people who have been in my situation."

Listen to Tim Mansel's radio documentary Returning Jihadis - A Danish Solution? for Assignment on the BBC World Service. Click here for transmission times, or to listen via the BBC iPlayer.

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.