Image caption Nabi was one of several hostages who escaped as Islamic State militants battled Taliban forces

A young Afghan man freed nearly nine months after being kidnapped by Islamic State fighters in Zabul province has been talking about his ordeal.

He was part of a group of hostages who were eventually freed by the Taliban and his story offers a rare glimpse inside the Islamic State group in Afghanistan.

Nabi's nightmare began back in February when armed men stopped the long-distance bus he was travelling in on the road from the western city of Herat to Kabul.

The 25-year old construction worker, who had recently got married, was on his way to the capital in the hope of finding work.

The gunmen, dressed in black and wearing masks, singled out passengers from the Shia Hazara minority, and drove 30 of them away to a remote village in the southern province of Zabul.

Initial reports blamed the Taliban for the attack, but after two days in captivity Nabi and his fellow hostages had a late-night visit from their kidnappers.

"They told us they were from Islamic State," Nabi recalls. "They said they wanted to exchange us for their women and children who were being held by the Afghan government."

The kidnappers said they were from neighbouring Uzbekistan, and that they had come to Afghanistan with their families "to take part in jihad".

"They spoke Uzbek among themselves and Dari with us," Nabi says. "They told us there were about 400 of them. They had big families and they all carried guns."

Image copyright EPA Image caption The freeing of some hostages was overshadowed by the brutal killing of seven others, reportedly by Islamic State militants - thousands turned out to mourn the victims

Image copyright EPA Image caption Afghan security forces have fought both Taliban insurgents as well as IS militants like here during an operation in Nangarhar province

Blindfolded

The kidnappers videoed their hostages, and after a few days separated them into two groups.

Nabi and his group were kept in an outbuilding used to house livestock.

"We were blindfolded and our hands were tied behind our backs," he says. "But our ears were open. We knew we were being held in a residential area because we could hear women and children's voices and the sound of the call to prayer."

Early on in their ordeal, government troops did try to rescue the men. They got close enough for the hostages to realise what was happening.

"Helicopters were flying overhead," Nabi says. "We could clearly hear the gunfire."

The rescue attempt failed and the government said that at this point they lost track of the hostages because they were being moved constantly.

Nabi disputes this, saying he was only moved four times during the nine months he was in captivity.

The hostages say they were treated with extreme brutality by their captors.

"Each one of them had his own particular way of torturing you," says Nabi.

They were regularly beaten and at one stage forced to appear in a video wearing suicide vests.

The worst point came when the kidnappers beheaded one of the hostages.

They filmed the murder in front of Nabi and the others, and in an echo of Islamic State atrocity videos in Syria, they wore black masks and hung up a black flag as a backdrop.

"We lost hope in everything except God," Nabi says. "The torture, the cruelty and the hardship made death seem like a much easier option than staying alive."

Image caption Nabi greets his father after his release

Unlikely rescue

Freedom finally came after local Taliban intervened and attacked the area being held by the IS fighters.

The hostages were moved to another location and held, still blindfolded, as heavy gunfire echoed overhead.

But after three days Nabi's captors melted away and armed men speaking Pashto appeared at the house.

"When we took off our blindfolds we saw a big man with a beard," says Nabi. "I realised they were Taliban and I felt relieved."

The group were taken to the house of a local Taliban commander.

"Around four or five hundred Taliban came to congratulate us," he says. "The commander told them not to hug us because we were too weak to stand on our feet at that stage."

Nabi says the Uzbek fighters and their families put up a big fight and some were killed or captured.

He saw some dead bodies and some injured fighters, but it's not clear what happened to the rest of the group.

Now back in Kabul where his parents, three brothers and two sisters live, Nabi is trying to recover from his ordeal.

He's clearly traumatised and has suffered kidney damage from the beatings he endured.

He is currently undergoing medical treatment and is unable to work or travel.

He told the BBC he had received no financial help from the government so far.