Image copyright Getty Images

In the late 1990s the Taliban controlled Afghanistan, but the fighting that brought them to power left many militants struggling with the psychological effects of war. One doctor recognised the problem and, although he disagreed with the Taliban's ideology, agreed to treat them.

"I remember the first group of Taliban who came to see me," says Afghan psychiatrist Nader Alemi. "They used to come in groups, not as individuals. When I treated one, he would spread the word.

"Fighters would turn up with my name on a piece of paper. They would say that I'd cured their friend, and now they wanted to be cured too. Most of them had never been to a doctor before."

A familiar figure in Afghanistan, Alemi is based in Mazar-e-Sharif in the north of the country. Taliban forces captured the city in August 1998 and won control of much of the surrounding area.

But while they were succeeding on the battlefield, Alemi saw the mental strain of years of fighting.

He was the only psychiatrist in northern Afghanistan to speak Pashto, the language of most Taliban.

"Language was very important - because I spoke their language, they felt comfortable opening up," he says.

One day the Taliban's provincial governor Akthar Osmani summoned Alemi to see him - Mullah Akhtar was second in command to Mullah Omar, the group's spiritual leader.

Image caption Afghan psychiatrist Nader Alemi at his clinic in Mazar-e-Sharif

"He was hearing voices and he was delusional - his bodyguards told me they could hear him raving during the night," says Alemi. Mullah Akhtar's staff also said their boss often didn't recognise them.

"This man had been on the front line for goodness knows how long, and seen goodness knows how many people killed in front of him. All those explosions and screams may still have been echoing in his head, even sitting in the comfort of his office."

Alemi wanted to see Mullah Akhtar regularly to provide long-term treatment, but his patient would go off on missions every three months, and only kept a few appointments. Much later, in 2006, Mullah Akhtar was killed in an airstrike.

Image copyright Getty Images Image caption Taliban fighters near the front line in 1995

Alemi treated other high-ranking Taliban officials too. "We became sort of friends. [One] asked me to see him at his headquarters - he was suffering from depression and chronic pain, and I prescribed him drugs to alleviate his symptoms."

"I don't remember the exact numbers who came to me, but it must have been in the thousands. I treated them for almost three years, before Mazar was recaptured in November 2001."

Because most of these patients had never been to a doctor before, Alemi asked if their commanders forbade it but that wasn't the case. "To be honest, they were so into their mission and daily routine that they didn't have time for medication. Surprisingly, all of them believed in my treatments.

"The reason they gave me for the turmoil in their minds was the uncertainty in their lives. They had no control over what was happening to them. Everything was in the hands of their commanders. They got depressed because they never knew what would happen from one minute to the next.

"Most of them hadn't seen their families for months - they hadn't seen their children who had grown big."

Alemi found many of the soldiers wanted to die. "They told me they [wanted] to commit suicide, but couldn't because of Islamic values."

One said: "Every time I go to the frontline, I wish someone would shoot me and bring an end to my life. But I still survive and hate this sort of living."

"I used to treat the Taliban as human beings, same as I would treat my other patients… even though I knew they had caused all the problems in our society," says Alemi. "Sometimes, they would weep and I would comfort them."

Mental health in Afghanistan

Image copyright Getty Images

In 2010 the health ministry said that two thirds of the population had a mental illness

Problems are mainly caused by continued violence, poverty, unemployment, domestic violence and drug addiction

A nationwide survey conducted by the US Centers for Disease Control and Prevention in 2002 found high levels of depression, anxiety, and PTSD (post-traumatic stress disorder) - women and people with disabilities were most affected

In 2006, the WHO reported that less than 1% of medical training was devoted to mental health

The few specialist hospitals that once existed have been replaced by a Mental Consultation Section in big state-run hospitals

One of the main problems was that Alemi's patients were often sent off on missions and could never commit to follow-up sessions.

Consultations cost the equivalent of $1 and the Taliban sometimes sent their wives and daughters to Alemi for treatment as well. "They too were suffering depression, because they wouldn't see their husbands, fathers for a long time and they didn't know what the future held for them."

Even the notorious religious police, the Amr Bil Ma'ruf, let him get on with his business. Alemi remembers how one day they were shouting on their loudspeakers, telling people to leave their jobs and get to mosque for prayers, but he was still seeing patients.

"One of my staff shouted from the building and said: 'The doctor is busy seeing patients'," says Alemi. The Amr Bil Ma'ruf shouted back and said: "It is alright, let him do his job."

Incredibly, at the same time that Alemi was treating the Taliban, his wife ran an underground school for about 100 girls - under the Taliban girls were not allowed to study.

Image copyright Getty Images Image caption Girls' schools reopened after the Taliban were removed from power

Parvin Alemi taught them about literature, language, maths and Islamic books. "All I wanted was to educate girls," she says. "Now some are doctors, engineers and teachers. They all appreciate what I did for them. They say they would have remained illiterate if I didn't educate them."

The pupils included the Alemis' own daughters - one is now a doctor and two are teachers.

But weren't they running a terrible risk? "I asked them to come separately, not in groups, to avoid any problems," says Parvin Alemi. "We kept the school secret. We asked our students not to tell anyone either. It was a dangerous decision, but I am proud to have taken the risk."

The couple were worried that the Taliban might catch them, but Alemi says they seemed to look upon him kindly. "Since I didn't have any political ambitions or interest, I am sure even if they caught our underground school, they would be cool about it because they knew all we wanted was to help others."

More than 15 years later, Alemi is still treating Afghans traumatised by conflict. The queues in his hospital stretch down the corridors, men and women in separate groups. They complain of depression, mood swings and nightmares.

Alemi says the biggest underlying problem in their lives is still uncertainty - they face hardship and deprivation and have no idea what the future holds.

Image caption Alemi's private neuro-psychiatric hospital in Mazar-e-Sharif

Nader Alemi appeared on Outlook on the BBC World Service. Listen to the interview again on iPlayer or get the Outlook podcast.

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