WASHINGTON - The Senate voted Thursday to confirm Gina Haspel as the next CIA director after several Democrats were persuaded to support her despite lingering concerns about her role in the brutal interrogation of suspected terrorists captured after 9/11.

The agency launched an unprecedented public relations campaign to bolster Haspel's chances. And she appears to have been helped by some last-minute arm-twisting by 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 Donald 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.

Following a nerve agent attack in Britain that American and British officials blamed on the Russian government, Haspel argued for a forceful response, which ultimately led to the U.S. expelling 60 Russian intelligence operatives and shuttering a Russian consulate in Seattle, people with knowledge of her role said. 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.

Read More: Bill Nelson will vote for Gina Haspel

Trump had wavered in his support for Haspel, at times expressing doubt in private meetings about whether she had the support to win confirmation, according to people with knowledge of the matter. 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.

Haspel's ascent to the top post in the nation's most storied spy service says much about the CIA's past and its future.

She will be the first woman to serve as director. When Haspel joined the CIA in 1985, there were fewer opportunities for women to live the life of a cloak-and-dagger operative that she found alluring. Haspel 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.

Her first chief of station assignment, in Baku, Azerbaijan, in 1996, prompted skepticism from male colleagues, who thought the CIA shouldn't send a woman to such a remote and rough location, according to people who worked with Haspel.

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-Qaida, 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.

In her bid to become the next director, Haspel and her supporters emphasized the historic nature of her nomination and how her career tracked with the rise of women in the intelligence services.

"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, Virginia.

Throughout her nomination, Haspel and her supporters struggled to reconcile her portrayal as a capable, forceful leader, but one who lacked the authority to stop the interrogation program or overrule her boss's decisions to order harsh interrogations and then destroy videotaped evidence.

Critics said she lacked the will to do so, and were unpersuaded that she had learned a moral lesson from the agency's torture of terrorist suspects - a program that was disbanded but that Trump has said should be restarted.

In late 2002, Haspel, then a senior leader in the Counterterrorism Center, managed a secret detention facility in Thailand where two al-Qaida 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.

"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," she said. "Until it does, the U.S. aligns itself with countries that undermine respect for fundamental rights and the rule of law."

During her confirmation hearing, 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.

A key to winning over skeptical Democrats was a letter Haspel wrote this week to Sen. Mark Warner, D-Va., the committee's vice chairman. "With the benefit of hindsight and my experience as a senior agency leader," Haspel wrote, "the enhanced interrogation program is not one the CIA should have undertaken."

But she stopped short of condemning the people "that made these hard calls," and again cited "valuable intelligence collected" through the program - despite the findings of the committee's report on torture, released in 2014, which concluded that the CIA's methods were not a viable means of gaining information.

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."