Shown here is Sgt. Bowe Bergdahl, who is being held by the Taliban. He is the only U.S. soldier to be captured in America’s longest war.

ISLAMABAD, Pakistan — Washington has held indirect talks with the Taliban over the possible transfer of five senior Taliban prisoners from Guantanamo Bay in exchange for a U.S. soldier captured nearly five years ago, a senior Taliban official told The Associated Press.

Sgt. Bowe Bergdahl, 27, of Hailey, Idaho, was last seen in a video released in December, footage seen as “proof of life” demanded by the United States. Bergdahl is believed to be held in the border regions between Afghanistan and Pakistan. He is the only U.S. soldier to be captured in America’s longest war, which began with the U.S.-led ouster of the Taliban regime in Afghanistan for sheltering al-Qaida in 2001 in the wake of the Sept. 11 terror attacks.

The talks, which the Taliban official said took place sometime over the past two months in a Middle East country, would be the first significant movement toward an exchange since it was last discussed by the U.S. and the Taliban in June 2013. That earlier initiative, along with the overall peace efforts, lost steam after Afghan President Hamid Karzai argued over the name of a Taliban political office that opened in the Gulf nation of Qatar. The office was eventually closed but several Taliban have remained behind in Qatar.

A U.S. official said the Americans are considering a prisoner exchange but would not comment on whether any new talks have taken place. The official, who has been closely involved with this issue and has knowledge of previous talks with the Taliban, refused to give more details.

State Department deputy spokeswoman Marie Harf would not confirm the efforts.

“We are not currently involved in active negotiations with the Taliban,” Harf said Wednesday. “Clearly if negotiations do resume at some point with the Taliban, then we would want to talk with them about the safe return of Sergeant Bergdahl.”

In Kabul, a senior Afghan official said the U.S. has recently been in touch with Karzai’s government over a possible exchange involving Berdahl, who was captured on June 30, 2009.

Time might be ripe for a swap.

Karzai has refused to sign a bilateral security agreement that would allow the U.S. to leave a residual force in Afghanistan after the NATO-led combat mission formally ends at the end of this year. Karzai says he must first see movement on reconciliation with the Taliban. He maintains that Washington has connections with the Taliban that can help with this process.

But there are potential roadblocks.

The five Taliban detainees currently are not among those Guantanamo Bay prisoners who have been approved for transfer once their home countries provide security guarantees. The Obama administration, which wants to close the facility, has argued that many approved transfers effectively have been blocked by rigid restrictions imposed by Congress. Recently, Congress eased the restrictions, including the toughest one, requiring the secretary of defense to “personally certify that there would be no recidivism for any detainee he certified,” according to Pentagon spokesman, Army Lt. Col. Todd Breasseale.

The transfer process, once it has begun, would take about two months, a senior U.S. official said, also speaking on condition of anonymity. Both U.S. officials and the Afghan official spoke on condition of anonymity because they were not authorized to discuss the issue publicly.

It was not clear where the five Taliban prisoners would go if released from Guantanamo Bay. Karzai has demanded that they be transferred to Afghanistan. The Taliban want them released to Qatar, suggesting they could be helpful with the peace process.

The senior Taliban official said leaders of the movement “are serious about the prisoners’ issue.” He said the talks were held through an intermediary and did not involve direct discussions with U.S. officials. He refused to give more details and spoke on condition of anonymity because he did not have Taliban leader Mullah Mohammed Omar’s permission to talk to the media.

The five Taliban detainees at the heart of the proposal are the most senior Afghans still held at the prison at the U.S. base in Cuba. Each has been held since 2002.

They include:

Mohammad Fazl, whom Human Rights Watch says could be prosecuted for war crimes for presiding over the mass killing of Shiite Muslims in Afghanistan in 2000 and 2001 as the Taliban sought to consolidate its control over the country.

Abdul Haq Wasiq, who served as the Taliban deputy minister of intelligence and was in direct contact with supreme leader Mullah Omar as well as other senior Taliban figures, according to military documents. Under Wasiq, there were widespread accounts of killings, torture and mistreatment.

Mullah Norullah Nori, who was a senior Taliban commander in the northern city of Mazar-e-Sharif when the Taliban fought U.S. forces in late 2001. He previously served as a Taliban governor in two northern provinces, where he has been accused of ordering the massacre of thousands of Shiites.

Khairullah Khairkhwa, who served in various Taliban positions including interior minister and a military commander and had direct ties to Mullah Omar and Osama bin Laden, according to U.S. military documents. His U.S. lawyers have argued in court papers that his affiliation with the Taliban was a matter of circumstance, rather than ideology, and that he had backed away from them by the time of his capture. His lawyers also have argued that he was merely a civil servant and had no military role, though a judge found otherwise and said there was enough evidence to justify holding him at Guantanamo. His lawyers have appealed.