Washington (CNN) Gina Haspel was confirmed Thursday to be the first female director of the CIA with the help of votes from a half-dozen Senate Democrats.

Haspel was confirmed in a 54-45 vote, the culmination of a roller-coaster nomination that appeared to be in danger at several points after she was abruptly selected by President Donald Trump in March.

Three Republicans opposed Haspel's nomination: Sens. Rand Paul of Kentucky, Jeff Flake of Arizona and John McCain of Arizona, although McCain did not vote because he's battling brain cancer at home.

But Haspel secured enough votes to win confirmation with the backing of six Democrats, including Virginia Sen. Mark Warner , the top Democrat on the Senate Intelligence Committee.

Most of the Democratic votes in favor of Haspel came from senators who are up for re-election in November in states that Trump won in 2016, including Sens. Joe Manchin of West Virginia, Joe Donnelly of Indiana, Heidi Heitkamp of North Dakota and Bill Nelson of Florida.

Sen. Jeanne Shaheen of New Hampshire also voted in favor of Haspel's confirmation.

Democrats who backed Haspel pointed to her 33-year CIA career, 32 years of which was spent undercover, as well as her broad support from former intelligence officials, including many senior Obama administration officials.

"Gina Haspel is among one of the most qualified people to be nominated to be director of the CIA," Warner said. "I feel safer knowing the CIA has Miss Haspel at the helm. ... I believe Gina Haspel should be confirmed. I look forward to supporting her."

But Haspel faced a barrage of criticism from some Democrats and human rights groups after she was picked in March to succeed Mike Pompeo as the nation's top spy, over her role in the George W. Bush administration's detention and interrogation program.

The criticism came on two fronts: Haspel ran a CIA black site in Thailand in 2002 where detainees were brutally interrogated with tactics that critics say is torture. And she drafted the cable that her boss sent to destroy dozens of CIA interrogation tapes in 2005.

"What I can say is her classified comments about her background have been as troubling as her public testimony," Democratic Sen. Ron Wyden of Oregon, a member of the Senate Intelligence Committee, said on the Senate floor Thursday.

The attacks on Haspel's record made Trump administration officials nervous about her nomination, especially after Paul announced his opposition, which meant Democrats had the ability to block Haspel's confirmation.

But the White House pushed forward on Haspel, and in her confirmation hearing last week she did enough to secure votes from Democrats who were on the fence, even as she repeatedly danced around questions about whether she thought the Bush-era interrogation program was immoral.

Senate Intelligence Chairman Richard Burr, a North Carolina Republican, said that Haspel has "consistently proven herself as a strong leader" on the Senate floor Thursday.

Haspel took one more step this week to get wavering Democrats on her side, sending Warner a letter on Tuesday in which she acknowledged that the interrogation program did damage to the CIA and should not have been conducted, which she didn't say in her public hearing.

Haspel's critics argued she still wouldn't say if she thought the interrogation program was immoral. And they expressed frustration that the CIA -- and Haspel herself -- refused to make public a full accounting of her CIA career and her role in the interrogation program.

They argued that the CIA selectively released details publicly about Haspel's career -- like the 2011 internal CIA report that cleared her of wrongdoing in the tapes' destruction -- in order to bolster her nomination.

The CIA did make classified materials about Haspel's record available to senators. But several of her opponents pointed to the fact that the Justice Department's report from the special counsel who investigated the destruction of the tapes was available only to senators on the Senate Intelligence Committee, and not the full body.

"My questions about Ms. Haspel's role in the destruction of videotapes relevant to discussions occurring in Congress regarding the program have not been adequately answered," Flake said in a statement announcing his opposition.

Burr, who argued that the report shouldn't have been made available to the Senate at all, said the CIA declassified everything that it was able to.

"She has earned the respect of the agency workforce, of her peers, of Republicans, of Democrats, of military officers, of civilian security leaders, evidenced by the number of letters received in support of her nomination too numerous to read," Burr said on the Senate floor.