The 368 prisoners, the last of more than 2500 Pakistanis captured during the overthrow of the Taliban, were being driven on Sunday by bus 250km to the Pakistani town of Peshawar for screening by Pakistani authorities.
"We are glad that their ordeal is finally over," said Pakistani embassy third secretary Zafar Ali Khan. "We have been trying to get access to them for a long time. We believe there has been no need to have kept them for so long in Afghan jails."
The prisoners, ranging in age from 22 to 60, were captured as the Taliban disintegrated in the face of the US-led invasion in November 2001.
Calls for jihad
Many had been drawn to Afghanistan from madrasahs or religious schools in Pakistan, attracted by the puritanical brand of Islam that the Taliban espoused.
"The mullahs in my area said that as Muslims we should go to Afghanistan to fight a jihad," 22-year-old Amir Khan, from Peshawar, told Reuters.
"I can not deny this was my intention. I arrived in Afghanistan in October. I spent three days in Kabul and then went to Mazar-i-Sharif. I was captured the day after I arrived there."
Like many of his comrades, Khan said he had received no military training and insisted he was a religious student who had been "misled" by the mullahs.
Scores of detainees have died in
Sold by mullahs
"They sold us," he said. "We learnt later that for every 10 mujahideen (holy warriors) that they sent, they would receive 5000 rupees ($100)."
Muhammad Afriqi, a 30-year-old from Pakistan's rugged North West Frontier Province, said he was among a group of 50 that surrendered to forces of Abd Al-Rashid Dostum in November 2001.
"They treated us very badly," he said. "Of those I was with, there are only about 20 left." He was initially held at the notorious Shiberghan prison, where Dostum's forces are accused of killing hundreds of prisoners or allowing them to die because of overcrowding.
In September 2002, Dostum issued a formal statement acknowledging that "approximately 200 prisoners died, but mostly of wounds suffered in the fighting, disease, suffocation, suicide and general weakness". Afriqi showed Reuters scars on his chest he said came from wounds caused by being whipped with an electric cable.
The prisoners said the past 18 months of their captivity had been much better than the initial stage, and on Sunday they all looked clean, fit and healthy.
"We learnt later that for every 10 mujahideen (holy warriors) that they (mullahs) sent, they would receive 5000 rupees"
"We have been here for three months," one prisoner said. It has been OK here."
Tristan Ferraro, detentions delegate for the International Committee of the Red Cross, said his organisation had not classified the Pakistanis as either prisoners of war or common criminals because their status was unclear.
But Afghan wardens at the prison said they had been treated as prisoners of war. It was not immediately clear if US authorities had access to the prisoners during their captivity.
The prisoner release follows a visit to Pakistan last month by President Hamid Karzai, who said all Pakistani prisoners would be freed once it was sure they would not harm Afghanistan.
US helicopter gunships killed up to 21 Taliban fighters trying to flee a joint US-Afghan assault in the southern province of Kandahar at the weekend, Afghan police said on Sunday.
"The Taliban were holed up in the village of Mooli with US and Afghan forces beseiging them", Salim Khan, the deputy police chief of Kandahar, told Reuters. "When they tried to flee, the US gunships opened fire on them and 21 were killed."