The Senate voted Thursday to confirm Gina Haspel as the next CIA director.

Several Democrats were persuaded to support her despite lingering concerns about her role in the brutal interrogation of suspected terrorists captured after 9/11.

She appears to have been helped by a public relations push by the agency and by some last-minute arm-twisting frp, former CIA directors John Brennan and Leon Panetta, who contacted at least five Democrats, all of whom agreed to endorse her bid to join President Trump’s Cabinet, according to people with knowledge of the interactions.

Haspel has not had as close of a relationship with Trump as the CIA’s previous director, Secretary of State Mike Pompeo, who is one of the president’s closest advisers, according to people with knowledge of Haspel and Trump’s interactions.

But she has been successful, to a degree, influencing the president’s stance toward Russia.

Haspel argued for a forceful response following a nerve agent attack in Britain that American and British officials blamed on the Russian government. Haspel was a leading player in the multiagency response to the attack and advised the president to make a bold demonstration to counter Russia and stand with Britain, the United States’ closest intelligence ally, these people said.

Earlier this month, Haspel sought to withdraw after some White House officials worried her role in the CIA’s nomination program could derail her chances.

Trump decided to push for Haspel to stay in the running, after first signaling he would support whatever decision she made, administration officials said.

She will be the first woman to serve as director. When Haspel joined the CIA in 1985, she took a posting as field officer in Ethiopia, an unglamorous assignment, but one that taught her how to run operations against agents for the Soviet Union, then a benefactor of the Ethiopian government.

Haspel’s request for a transfer to the CIA’s Counterterrorism Center proved to be a fateful move. Her first day on the job was Sept. 11, 2001, and she became an integral part of the CIA’s early operations against al-Qaeda, according to current and former colleagues. At the time, counterterrorism was also a less coveted assignment, and an area where women were getting significant jobs and excelling at them.

Haspel and her supporters emphasized the historic nature of her nomination.

“It is not my way to trumpet the fact that I am a woman up for the top job, but I would be remiss in not remarking on it — not least because of the outpouring of support from young women at CIA who consider it a good sign for their own prospects,” Haspel told senators at her confirmation hearing last week.

But it is the dark chapters of Haspel’s past — and that of the CIA — that imperiled her nomination from the start and will not be closed as she takes over at the agency’s headquarters in Langley, Va.

In late 2002, Haspel, then a senior leader in the Counterterrorism Center, managed a secret detention facility in Thailand where two al-Qaeda suspects were waterboarded, one of them before Haspel’s arrival.

Laura Pitter, a national security counsel at Human Rights Watch, called Haspel’s confirmation “the predictable and perverse byproduct” of the United States’ failure to reconcile with past abuses.

Haspel insisted she would never allow torture at the CIA again, and she said she’d be guided in the future by her own “moral compass.” But she resolutely avoided saying whether, at the time, she thought the detention and interrogation of suspected terrorists was moral.

Most Democrats did not come round to Haspel’s side. Those who did are betting that Haspel, despite her intimate role in some of the CIA’s darkest operations, is the best person to ensure they’re not repeated.

“This was not an easy decision,” Sen. Heidi Heitkamp (D-N.D.), who faces a tough Republican challenge this year, said in a statement explaining her support.

“Ms. Haspel’s involvement in torture is deeply troubling as my friend and colleague, John McCain, so eloquently reminded us,” Heitkamp said. McCain, himself a survivor of torture in North Vietnamese prisons, had called on his colleagues to reject Haspel’s nomination, saying her “refusal to acknowledge torture’s immorality is disqualifying.”

Heitkamp said she was persuaded, though, by her one-on-one meetings with Haspel. She “explained to me that the agency should not have employed such tactics in past and has assured me that it will not do so in the future.”

The major reason many women running for office may lose

ANALYSIS | Bad news about the influx of women fighting their way into the political ring

Cynthia Nixon’s sexuality misrepresented in first battle of campaign

It’s likely not the last time