Photo
President Ashraf Ghani, center, with former President Hamid Karzai, left, whose government received monthly C.I.A. payments. CreditOmar Sobhani/Reuters 
WASHINGTON — In the spring of 2010, Afghan officials struck a deal to free an Afghan diplomat held hostage by Al Qaeda. But the price was steep — $5 million — and senior security officials were scrambling to come up with the money.
They first turned to a secret fund that the Central Intelligence Agency bankrolled with monthly cash deliveries to the presidential palace in Kabul, according to several Afghan officials involved in the episode. The Afghan government, they said, had already squirreled away about $1 million from that fund.
Within weeks, that money and $4 million more provided from other countries was handed over to Al Qaeda, replenishing its coffers after a relentless C.I.A. campaign of drone strikes in Pakistan had decimated the militant network’s upper ranks.
“God blessed us with a good amount of money this month,” Atiyah Abd al-Rahman, the group’s general manager, wrote in a letter to Osama bin Laden in June 2010, noting that the cash would be used for weapons and other operational needs.
Photo
Abdul Khaliq Farahi, who was kidnapped by Al Qaeda in 2008. CreditMichael Kamber for The New York Times 
Bin Laden urged caution, fearing the Americans knew about the payment and had laced the cash with radiation or poison, or were tracking it. “There is a possibility — not a very strong one — that the Americans are aware of the money delivery,” he wrote back, “and that they accepted the arrangement of the payment on the basis that the money will be moving under air surveillance.”
The C.I.A.’s contribution to Qaeda’s bottom line, though, was no well-laid trap. It was just another in a long list of examples of how the United States, largely because of poor oversight and loose financial controls, has sometimes inadvertently financed the very militants it is fighting.
While refusing to pay ransoms for Americans kidnapped by Al Qaeda, the Taliban or, more recently, the Islamic State, the United States has spent hundreds of billions of dollars over the last decade at war in Iraq and Afghanistan, some of which has been siphoned off to enemy fighters.
The letters about the 2010 ransom were included in correspondence between Bin Laden and Mr. Rahman that was submitted as evidence by federal prosecutors at the Brooklyn trial of Abid Naseer, a Pakistani Qaeda operative who was convicted this month of supporting terrorism and conspiring to bomb a British shopping center.
The letters were unearthed from the cache of computers and documents seized by Navy SEALs during the 2011 raid in which Bin Laden was killedin Abbottabad, Pakistan, and had been classified until introduced as evidence at the trial.
Details of the C.I.A.’s previously unreported contribution to the ransom demanded by Al Qaeda were drawn from the letters and from interviews with Afghan and Western officials speaking on the condition of anonymity because of the sensitivity of the issue. The C.I.A. declined to comment.
The diplomat freed in exchange for the cash, Abdul Khaliq Farahi, was serving as the Afghan consul general in Peshawar, Pakistan, when he was kidnapped in September 2008 as he drove to work. He had been weeks away from taking up his new job as Afghanistan’s ambassador to Pakistan.
Afghan and Pakistani insurgents had grabbed Mr. Farahi, but within days they turned him over to Qaeda members. He was held for more than two years.
The Afghan government had no direct contact with Al Qaeda, stymieing negotiations until the Haqqani network, an Afghan insurgent faction with close ties to Al Qaeda, stepped in to mediate.
Qaeda leaders wanted some captive militants released, and from the letters it appeared that they calibrated their offer, asking only for men held by Afghan authorities, not those imprisoned by the Americans, who would refuse the demand as a matter of policy. But the Afghans refused to release any prisoners, “so we decided to proceed with a financial exchange,” Mr. Rahman wrote in the June 2010 letter. “The amount we agreed on in the deal was $5 million.”
Photo
A 2009 surveillance video image of Abid Naseer, right, who was convicted this month in a bombing plot. CreditU.S. Attorney's Office, via Associated Press 
The first $2 million was delivered shortly before that letter was written. In it, Mr. Rahman asked Bin Laden if he needed money, and said “we have also designated a fair amount to strengthen the organization militarily by stockpiling good weapons.” (The Qaeda leaders named in the letters were identified by aliases. Bin Laden, for instance, signed his letters Zamray; Mr. Rahman, who was killed in a drone strike in Pakistan in August 2011, went by the alias Mahmud.)
The cash would also be used to aid the families of Qaeda fighters held prisoner in Afghanistan, and some was given to Ayman al-Zawahri, who would succeed Bin Laden as the Qaeda leader and was identified in the letters under the alias Abu-Muhammad, Mr. Rahman said.
Other militant groups had already heard about the ransom payment and had their hands out, Mr. Rahman reported. “As you know, you cannot control the news,” he wrote. “They are asking us to give them money, may God help us.”
But Bin Laden was clearly worried that the payout was an American ruse intended to reveal the locations of senior Qaeda leaders. “It seems a bit strange somewhat because in a country like Afghanistan, usually they would not pay this kind of money to free one of their men,” he wrote.
“Is any of his relatives a big official?” he continued, referring to Mr. Farahi, the diplomat. It was a prescient question: Mr. Farahi was the son-in-law of a man who had served as a mentor to then-President Hamid Karzai.
Advocating caution, Bin Laden advised Mr. Rahman to change the money into a different currency at one bank, and then go to another and exchange the money again into whatever currency was preferred. “The reason for doing that is to be on the safe side in case harmful substances or radiation is put on paper money,” Bin Laden wrote.
Neither of the two men appeared to have known where the money actually came from. Aside from the C.I.A. money, Afghan officials said that Pakistan contributed nearly half the ransom in an effort to end what it viewed as a disruptive sideshow in its relations with Afghanistan. The remainder came from Iran and Persian Gulf states, which had also contributed to the Afghan president’s secret fund.
In a letter dated Nov. 23, 2010, Mr. Rahman reported to Bin Laden that the remaining $3 million had been received and that Mr. Farahi had been released.
The C.I.A., meanwhile, continued dropping off bags of cash — ranging each time from a few hundred thousand dollars to more than $1 million — at the presidential palace every month until last year, when Mr. Karzai stepped down.
The money was used to buy the loyalty of warlords, legislators and other prominent — and potentially troublesome — Afghans, helping the palace finance a vast patronage network that secured Mr. Karzai’s power base. It was also used to cover expenses that needed to be kept off the books, such as clandestine diplomatic trips, and for more mundane costs, including rent payments for the guesthouses where some senior officials lived.
The cash flow has slowed since a new president, Ashraf Ghani, assumed office in September, Afghan officials said, refusing to elaborate. But they added that cash was still coming in, and that it was not clear how robust any current American constraints on it are.
“It’s cash,” said a former Afghan security official. “Once it’s at the palace, they can’t do a thing about how it gets spent.”