Incoming Central Intelligence Agency director Gina Haspel stands for the national anthem during her swearing-in ceremony at CIA Headquarters, Monday, May 21, 2018, in Langley, Virginia. Credit: Evan Vucci | AP

LANGLEY, Virginia — As he participated in the swearing-in of his new CIA director on Monday, President Donald Trump acknowledged the difficulties that Gina Haspel’s nomination had faced but said her strong performance at her confirmation hearing turned things around.

“It took courage for her to say ‘yes’ in the face of a lot of very negative politics and what was supposed to be a negative vote,” Trump said at a ceremony at CIA headquarters in Langley, Virginia. “But I’ll tell you, when you testified before the committee, it was over. There was not much they could say.”

The Senate voted Thursday to confirm Haspel’s nomination, 54 to 45, despite lingering concerns about the role she played in the brutal interrogation of suspected terrorists captured after the Sept. 11, 2001, attacks.

Haspel, who succeeds Mike Pompeo, Trump’s new secretary of state, is the first woman to lead the CIA. Trump noted the milestone in his remarks, adding: “That’s big.”

Trump praised Haspel, who rose through the ranks at the CIA, as “someone who has served this agency with extraordinary skill and devotion” for 30 years.

“Our enemies will take note,” Trump said. “Gina is tough, she is strong, and when it comes to defending America, Gina will never, ever back down.”

Trump had wavered in his backing 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 that her involvement in the CIA’s interrogation 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.

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

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

From the moment she was nominated to succeed Pompeo, Haspel had faced major confirmation hurdles. Sen. Rand Paul, R-Kentucky, announced from the outset that he would oppose her, while she faced deep skepticism from Democrats and other Republicans for her role in the enhanced interrogation program during the administration of George W. Bush.

Haspel, however, sailed through her confirmation hearing before the Senate Intelligence Committee without any major slip-ups, and former defense and intelligence officials under the Obama administration mounted a campaign to persuade swing Democratic votes.

On Thursday, six Democratic senators supported her nomination, and two Republicans voted against her – Paul and Arizona Sen. Jeff Flake.

During remarks after she was sworn in Monday by Vice President Mike Pence, Haspel noted that “it has been nearly 50 years since an operations officer rose up through the ranks” to become CIA director.

After her two-month-long confirmation battle, Haspel added: “I think I know why that is.”

“I want each of you to know that I took on the position of director because I want to represent you, as well as lead you,” Haspel said to CIA employees present at the ceremony. “I want the current CIA leadership team to be role models and mentors for our next generation of officers.”

Former senior intelligence officials attended the swearing-in ceremony, but former CIA Director John Brennan was not invited, according to people familiar with the matter. Brennan, who led the agency during President Barack Obama’s administration, has become a fierce and vocal critic of Trump, accusing him of behavior that he recently characterized as “self-serving” and dangerous to democracy.

In various tweets in recent weeks, Brennan has called Trump a hypocrite and a liar. On Sunday, Brennan called on Senate Majority Leader Mitch McConnell, R-Ky., and House Speaker Paul Ryan, R-Wis., to prevent the president from ordering a Justice Department investigation into the probe of his presidential campaign’s contacts with Russia.

“If Mr. Trump continues along this disastrous path, you will bear major responsibility for the harm done to our democracy,” Brennan wrote in a tweet.

On Monday morning, Trump, in an apparent response, alleged that Brennan had orchestrated the Russia investigation as a “political hit job” against the president. (There is no evidence that Brennan was the source of the investigation.) Trump was quoting Dan Bongino, a former U.S. Secret Service agent and frequent Fox News commentator.

The Washington Post’s Shane Harris and Karoun Demirjian contributed to this report.

Follow the Bangor Daily News on Facebook for the latest Maine news.