By Kay Johnson and Saud Mehsud
KABUL/DERA ISMAIL KHAN, Pakistan (Reuters) - The United States has handed to Pakistan three prisoners including a senior Taliban militant held in Afghanistan, as Washington rushes to empty its Afghan prison before losing the legal right to detain people there at the end of the year.
U.S. forces captured Latif Mehsud, a top deputy in Pakistan's faction of the Taliban, in October 2013, in an operation that angered then Afghan president Hamid Karzai.
Mehsud, a Pakistani, and his two guards were secretly flown to Pakistan, two senior Pakistani security officials told Reuters. The U.S. military confirmed it transferred three prisoners to Pakistan's custody on Saturday, but would not reveal their identities.
"TTP senior commander Latif Mehsud who was arrested was handed over to Pakistani authorities along with his guards," one Pakistani security official said. "They reached Islamabad."
The U.S. Embassy in Kabul said three prisoners had been held at a detention center near Bagram airfield, the largest U.S. base in Afghanistan.
The facility is believed to house several dozen foreign prisoners who the United States will no longer be allowed to keep in Afghanistan when the mission for the U.S.-led force there ends later this month.
"We're actually just going through and returning all the third-country nationals detained in Afghanistan to resolve that issue," a U.S. embassy spokeswoman said.
Taliban militants fired two rockets into the Bagram base on Saturday, damaging a building and a road, a spokesman for international coalition forces said.
Recognizable by his curly locks and youthful looks, Mehsud was a senior deputy in the Pakistani faction of the Taliban when U.S. forces snatched him last year, not far from Kabul.
At the time, Karzai's spokesman told the Washington Post Mehsud was traveling with a convoy of Afghan intelligence officials who wanted to recruit him for peace talks, and that the U.S forcibly removed him.
The arrest enraged Karzai, who saw it as a challenge to Afghan sovereignty. In a statement, the U.S. military said Afghanistan "was not involved" in the transfer.
"We are working on gathering information on how this took place," said Nazifullah Salarzai, the spokesman for Afghan President Ashraf Ghani.
Relations between the two neighbors were rocky because each suspects the other of harboring Taliban insurgents. The Afghan and Pakistani Taliban are separate but allied and both work alongside al Qaeda.
The strained ties between Afghanistan and Pakistan improved slightly after Ghani got a warm welcome from Pakistani Prime Minister Nawaz Sharif during a state visit last month.
(Writing and additional reporting by Frank Jack Daniel in Kabul, Katharine Houreld in Islamabad and Mohammad Anwar in Asadabad, Afghanistan; Editing by Stephen Powell)