Mr. Salehi was released seven hours later, after telephoning Mr. Karzai from his jail cell to demand help, officials said, and after Mr. Karzai forcefully intervened on his behalf.

The president sent aides to get him and has since threatened to limit the power of the anticorruption unit that carried out the arrest. Mr. Salehi could not be reached for comment on Wednesday. A spokesman for President Karzai did not respond to a list of questions sent to his office, including whether Mr. Karzai knew that Mr. Salehi was a C.I.A. informant.

A spokesman for the C.I.A. declined to comment on any relationship with Mr. Salehi.

“The C.I.A. works hard to advance the full range of U.S. policy objectives in Afghanistan,” said Paul Gimigliano, a spokesman for the agency. “Reckless allegations from anonymous sources don’t change that reality in the slightest.”

An American official said the practice of paying government officials was sensible, even if they turn out to be corrupt or unsavory.

“If we decide as a country that we’ll never deal with anyone in Afghanistan who might down the road  and certainly not at our behest  put his hand in the till, we can all come home right now,” the American official said. “If you want intelligence in a war zone, you’re not going to get it from Mother Teresa or Mary Poppins.”

Last week, Senator John Kerry, the Massachusetts Democrat, flew to Kabul in part to discuss the Salehi case with Mr. Karzai. In an interview afterward, Mr. Kerry expressed concern about Mr. Salehi’s ties to the American government. Mr. Kerry appeared to allude to the C.I.A., though he did not mention it.

“We are going to have to examine that relationship,” Mr. Kerry said. “We are going to have to look at that very carefully.”