A career CIA officer deeply involved in its post-9/11 torture program will be Donald Trump’s next director of the premiere U.S. spy agency, the Senate ensured on Thursday.

In what quickly coalesced into a foregone conclusion this week, Gina Haspel won sufficient support in the Senate, thanks to nearly lockstep support from the Republican majority and pivotal votes from several Senate Democrats, to run Langley.

The vote was 54 to 45, with six Democrats—Joe Donnelly, Mark Warner, Bill Nelson, Jeanne Shaheen, Heidi Heitkamp, and Joe Manchin—backing Haspel. Only Republicans Jeff Flake and Rand Paul opposed her on the floor, as did an ailing John McCain, who was not present to vote. It was the slimmest Senate margin for a CIA director in the agency’s history.

“I will feel safer knowing the CIA has Ms. Haspel at the helm,” said Senate intelligence committee ranking Democrat Warner, whose backing of Haspel all but assured her directorship.

Haspel’s victory came after an aggressive public campaign by the CIA to install her as its director by emphasizing her fandom of Kentucky college basketball and Johnny Cash, rather than her time running a black site in Thailand where interrogators under her command tortured a man. And it occurred after Haspel, until now the agency’s acting director, rejected extensive requests to declassify her own torture record, which anti-torture senators and human rights groups said was necessary for an informed vote.

The CIA instead provided senators with documents on her agency record, which they could only read behind closed doors—and which Senate bipartisan leadership cut short by fast-tracking the Haspel floor vote to the day after Haspel won the support of the Senate intelligence committee.

“What the Senate is doing now is an insult to the public and an abdication of this body’s constitutional responsibilities. It is as stark a failure of oversight as I have ever seen,” said Ron Wyden, an Oregon Democrat on the intelligence committee, on the Senate floor, who called the agency’s promotion of Haspel “an unprecedented influence campaign.”

Human-rights groups and anti-torture senators considered Haspel’s confirmation a debacle.

“The U.S. Senate’s confirmation of Gina Haspel for CIA director is the predictable and perverse byproduct of the U.S. failure to grapple with past abuses,” said Laura Pitter of Human Rights Watch.

“The torture at the center of the CIA’s rendition, detention, and interrogation program was a crime plain and simple, but the U.S. government has never been willing to admit that or to take appropriate action. Until it does, the U.S. aligns itself with countries that undermine respect for fundamental rights and the rule of law.”

From late October to early December 2002, close to the dawn of the post-9/11 torture program, Haspel was chief of base at a black site in Thailand. There, Abd al-Rahim al-Nashiri, a suspect in the USS Cole bombing that killed 17 sailors in Yemen, was waterboarded, stuffed into a small box, lifted by his restrained arms until it seemed like they would dislocate, and subjected to other abuses. Al-Nashiri’s attorneys have described lasting mental damage from his time in CIA captivity.

Haspel, a career CIA officer, returned to the agency’s Counterterrorism Center, where she worked for nearly two more years—a period when the torture program, run by the Center, was at its height. At least 119 men were tortured, according to the 2014 Senate torture report, with an unknown but presumed to be larger number sent to foreign countries for outsourced torture, a process known as “extraordinary rendition.” Haspel, in her confirmation hearing last week, refused to specify in public her role in torture while back at the Counterterrorism Center.

Yet a memoir from one of the CIA’s seniormost lawyers at the time, John Rizzo, claimed that by 2005, Haspel had “previously run the interrogation program,” a description Rizzo told The Daily Beast for a mid-April story he stood behind. After The Daily Beast published its story, however, Rizzo suddenly claimed to have misremembered Haspel’s prominence in torture, four years after his book was published. Rizzo’s newfound memory was convenient for Haspel’s nomination, who cited his retraction under questioning at her confirmation hearing.

Both at the Counterterrorism Center and later at the National Clandestine Service (NCS), Haspel worked for Jose Rodriguez, one of the leading CIA figures in charge of the torture program and, in his retirement, a leading defender of it as necessary to save American lives. While serving as Rodriguez’s chief of staff at the NCS, Haspel drafted a November 2005 cable ordering the destruction of 92 2002-era videotapes showing the torture of both al-Nashiri and the CIA’s first detainee, Abu Zubaydah.

Haspel, at her confirmation hearing, erroneously insisted that only one detainee was taped, something she corrected in official questions for the record without acknowledging either that she was wrong or that she served in a command position at the black site where the torture tapes were made. She conceded, however, that she was an “advocate” of destroying the tapes—something that brought her under federal investigation for destruction of evidence, though the probe ended in 2010 without charges.

“The DOJ [Justice Department] recommended Haspel be held accountable for the destruction of CIA interrogation tapes. And the tapes were destroyed, in part, in fear Congress would see them. The CIA ignored the recommendation. And Haspel kept being promoted,” Daniel J. Jones, the lead investigator of the Senate torture report and a former FBI counterterrorism analyst, told The Daily Beast.

In its public portrayal of Haspel as a gender pioneer and an intelligence officer par excellence, the CIA played down Haspel’s torture record, tacitly arguing that it ought to be considered a footnote to a storied career. Yet Trump, who has publicly enthused about torture, blasted the opposition to Haspel’s directorship by saying she had “come under fire because she was too tough on Terrorists,” indicating that Trump considered Haspel’s involvement in torture to be a credential.

While former CIA colleagues who have promoted Haspel’s nomination have portrayed her as a check on Trump, Haspel had nothing but praise for Trump at her confirmation hearing, who she said had shown “enormous respect” for a CIA he once compared to Nazis.

“What about the next” brutal act that Trump requests of her, said Sen. Patrick Leahy (D-Vt.) ahead of the vote Thursday. “Should we trust she’ll have the moral compass to stand up and say no?”

Haspel would not criticize the torture program at her confirmation hearing. She rebuffed numerous opportunities to describe torture as immoral— something McCain, who survived Viet Cong torture, considered disqualifying—even as she insisted she would not restart it. In a subsequent letter, which was critical to securing the support of intelligence committee top Democrat Mark Warner, Haspel described the torture program as a mistake, not because of the brutality it visited upon CIA detainees, but because it “did damage to our officers and our standing in the world.” She wrote that she would not “condemn those [at CIA] who made those hard calls.”

Warner, on the Senate floor Thursday, called Haspel “among the most qualified people to be nominated to be CIA director.”

Haspel, who will be the agency’s first woman director, has a deep well of support within Langley. Her victory is a signal moment for a CIA that was willing not only to torture people—an act illegal at the time, despite an ultimately withdrawn August 2002 Justice Department blessing—but to spy on Senate staffers tasked with investigating the torture program. Before and after the Senate’s torture report was published in 2014, the CIA blasted the investigation as biased, even as it moved away from an explicit defense of torture.

Human rights advocates, who in March thought Haspel was beatable, have warned that the CIA will consider a Director Haspel to be a vindication of both its torture and its efforts at obscuring the program.

“From the outside, I find it hard to understand how any member committed to legitimate oversight would support the Haspel nomination,” said Jones, the lead torture-report investigator.

“The Senate found the CIA repeatedly provided inaccurate information to Congress on the techniques and their effectiveness. And that this happened under both the Bush and Obama administrations. This is not a partisan issue.”

Jones continued: “What message does this confirmation send to the world, and to the CIA workforce? If the Senate intelligence committee doesn’t hold CIA officers to account, who will?”