A retired CIA official detained in Panama has been released and was en route to the U.S. on Friday, State Department spokeswoman Marie Harf said.

U.S. officials had been negotiating with Panamanian authorities to get the retired spy, Robert Lady, released and returned to the U.S., according to a source familiar with the efforts. It was not immediately clear why Lady was in Panama.

Lady, who was tried and sentenced in absentia by an Italian court for his role in the 2003 CIA “extraordinary rendition” of an Egyptian cleric, was detained Wednesday by Panamanian authorities after crossing that country’s border with Costa Rica.

His release from Panama was first reported by the Washington Post.

It was unclear under what authority Panama detained Lady. The Italian government had previously issued an international notice that he was wanted in connection to his sentence there. An Interpol spokesperson said Lady was not listed on any public arrest lists but said it was possible Lady was on a “restricted” list.

Lady was one of 26 Americans charged and convicted for the rendition of Osama Mustafa Hassan Nasr, known as Abu Omar, from a Milan street in February 2003. Abu Omar was shuttled from Milan to Cairo and handed over to Egyptian intelligence for interrogation, where he alleged he was tortured for seven months. He was later released from prison without a charge.

Related story

Former CIA agent wanted in Italy 'rendition' case detained in Panama

Since the first round of convictions in 2009, Italian justice officials have tried to get custody of the 26 Americans, but no Italian government has ever officially requested extradition.

The rendition program involved U.S. operatives capturing suspected terrorists and transferring them to a third country, where they were charged, detained or interrogated. The CIA rendered suspected terrorists to Egypt, Jordan, Morocco, as well as several European nations where the CIA maintained secret “black site” prisons for top al Qaeda detainees.

More from NBC News Investigations:

Follow NBC News Investigations on Twitter and Facebook