WASHINGTON — The Pentagon secretly repatriated two Tunisians who were interrogated at a CIA black site in Afghanistan and imprisoned by the U.S. military in that country for more than a decade, U.S. officials said.

A U.S. military cargo plane flew Lutfi al-Arabi al-Gharisi and Ridha Ahmad al-Najjar from Afghanistan to Tunisia on June 15, according to U.S. officials, who spoke on the condition of anonymity to discuss a detainee transfer that had not been made public.

The Pentagon on Friday confirmed the transfer of the two men who were being held in Afghan government custody prior to their repatriation by the U.S. military, which said the flight was done in support of the Afghan government.

Two Afghan officials accompanied the prisoners on the flight because it was considered a joint operation.

“These individuals remained under Afghan government control until they were handed over to Tunisian officials,” said Lt. Col. Myles Caggins, a Pentagon spokesman.

Tina Foster, a lawyer for Gharisi and Najjar, said the men had been freed by the Tunisian government.

The transfer came six months after the United States officially ended more than a dozen years of detainee operations in Afghanistan, a notable step in the Western military departure from the country.

In December, the Pentagon said it had transferred all prisoners remaining in its custody in Afghanistan to the local government. Najjar and Gharisi were the last prisoners to be moved into Afghan custody.

The transfer also underscores Afghanistan’s continuing reliance on foreign military capability even as NATO nations step back from combat operations in the country. Afghanistan in particular has struggled to build an effective air force.

The transfer ends a 13-year detention for Najjar, who the CIA suspected was a bodyguard for al-Qaida leader Osama bin Laden. Najjar was captured in Karachi, Pakistan, in May 2002 and taken about three months later to the secret CIA site in neighboring Afghanistan known as Salt Pit. He was the CIA’s first detainee at the facility, a notorious secret prison.

According to a Senate report on the agency’s detention and interrogation program, CIA interrogators described Najjar after lengthy interrogations as “clearly a broken man” and “on the verge of a complete breakdown.”

In a cable, interrogators said Najjar was willing to do whatever the CIA asked.

The report said CIA personnel left Najjar hanging — handcuffed and wearing a diaper — from an overhead bar for 22 hours each day for two consecutive days, in order to “break” his resistance. The CIA also signed off on a plan to hood Najjar, deprive him of sleep and expose him to loud music.

Not much is known about Gharisi’s capture or time in CIA custody. The Senate report said he was one of 17 CIA detainees who were subjected to certain interrogation techniques without approval of the agency’s headquarters.

The Senate report says Najjar was held by the CIA for at least 700 days. The CIA detained Gharisi for approximately 380 days before they were both transferred to U.S. military custody in Afghanistan.

Most U.S. prisoners in Afghanistan, who for years included Afghans and prisoners of other nationalities, were held at a facility at Bagram air base, outside of the Afghan capital, Kabul.

As the United States gradually restricted its military role in Afghanistan, U.S. officials transferred Afghan prisoners to local government custody but retained control of the foreign nationals until December 2014.

Washington Post staff writer Julie Tate contributed to this report.