CIA Director John Brennan testifies before the Senate Select Intelligence Committee during his confirmation hearing on Feb. 7. (Manuel Balce Ceneta/AP)

A CIA officer who was the first woman to lead the agency’s clandestine service, but was also directly involved in its controversial interrogation program, will not get to keep that job as part of a management shake-up announced Tuesday by CIA Director John O. Brennan.

The officer, who is undercover, served as director of the National Clandestine Service on an interim basis over the past two months, and many considered her a front-runner to keep the post, which involves overseeing the CIA’s spying operations worldwide.

But she faced opposition because of her extensive role in an interrogation program that critics have said relied on torture to get information from al-Qaeda captives after the Sept. 11, 2001, attacks. She had run a secret prison in Thailand where two detainees were subjected to waterboarding and other harsh techniques. She later helped order the destruction of videotapes of those interrogation sessions.

Instead, Brennan has given the job to a 57-year-old longtime officer who served tours in Pakistan and Africa and was recently in charge of the agency’s Latin America division, according to public records and former officials. He is also undercover, U.S. officials said.

The CIA confirmed the appointment in a statement Tuesday but disputed that the female officer’s ties to the interrogation program were a factor.

“The assertion she was not chosen because of her affiliation with the CT mission is absolutely not true,” said CIA spokeswoman Jennifer Youngblood, using an abbreviation for counterterrorism.

Youngblood described the new head of the spy service as a “talented and effective intelligence officer” who “is known for his collaborative and inclusive leadership style.” She noted that women will fill two other senior CIA jobs.

The moves mark the resolution of an early quandary for Brennan, who faced a bruising confirmation fight over his own ties to the interrogation program. He had taken the unusual step of forming a panel of retired CIA officers to evaluate candidates for the clandestine service position.

The female officer, who is in her 50s, had support within the agency and had served as deputy director of the clandestine service. But her background posed political problems at a time when the controversy over the agency’s treatment of detainees has reemerged.

The CIA is assembling what former officials have described as a defiant response to a 6,000-page report recently completed by the Senate Intelligence Committee that sharply criticizes the interrogation program as well as the agency’s claims about its results.

The report contains many references to the female officer’s role.

Sen. Dianne Feinstein (D-Calif.), chairman of the panel, had called Brennan to express concern that someone so closely linked to the program might lead the agency’s spying service.

After running the “black site” in Thailand, the female officer returned to headquarters for a senior job at the CIA’s Counterterrorism Center. Former colleagues said she lobbied for several years to have the videotapes taken in Thailand destroyed.

The 2005 destruction of the tapes, which went against White House lawyers’ warnings, prompted a criminal investigation, but no charges were filed.

To help navigate the clandestine service decision, Brennan assembled a group of advisers that included former senior CIA officials John McLaughlin, Stephen Kappes and Mary Margaret Graham. McLaughlin declined to discuss the group’s deliberations, but said in an e-mail that the interim spy chief and her successor “are very fine officers with wide-ranging and successful experience both substantively and in terms of developing and leading people.”

He added that “past counterterrorism policy simply did not come up and was not a factor.”

The new spy chief is a Marine Corps veteran who initially joined the CIA’s paramilitary branch but spent most of his career in traditional espionage assignments. He assumes control at a time when Brennan has signaled concern that intelligence collection has been hampered by the agency’s emphasis on drone strikes.

The names of both officers are widely known in the intelligence community, but the agency requested that they not be identified because they are undercover. The female officer is expected to resume her prior role as deputy of the clandestine service.

Brennan’s decision was complicated by the agency’s history of gender imbalance in its upper ranks. No woman has ever served as director or deputy director of the CIA, and none had been head of the clandestine service until the female officer was elevated to that role on an interim basis when her predecessor retired.

A former senior CIA official, speaking on the condition of anonymity, said that women at the agency “will be outraged” that the female officer was denied the job. “She is very popular. She is an excellent officer and very good administrator.”

The CIA’s statement identified the two women chosen for senior posts as Meroe Park, who was named executive director, and Deb Bonk, who will serve as Brennan’s chief of staff. “Women will hold fully half of the positions” on Brennan’s leadership team, Youngblood said.

Julie Tate contributed to this report.