The U.S. Senate narrowly confirmed Kash Patel to lead the FBI and carry out Donald Trump’s vision for overhauling an agency that the president claims has been weaponized against him and other conservatives.

Patel, 44, who was approved on a 51-49 mostly party line vote, takes over the FBI at a turbulent time. The new administration has already fired or reassigned dozens of Justice Department and FBI officials and demanded a list of about 5,000 bureau personnel who worked on investigations into Trump and rioters at the U.S. Capitol on Jan. 6, 2021.

The bureau is a key part of Trump’s government reform agenda, after he was investigated by its agents in two cases that resulted in criminal indictments. One of Trump’s first executive orders after being inaugurated was "to correct past misconduct by the federal government related to the weaponization of law enforcement and the weaponization of the intelligence community.”

Two Republican Senators, Susan Collins of Maine and Lisa Murkowski of Alaska, joined 47 Democrats in voting against Patel’s confirmation.

Patel overcame intense opposition during his confirmation process, especially from Democrats who argued he isn’t qualified to lead the agency with 38,000 employees. Critics also cited statements and social media posts Patel made before his nomination, such as saying he would shutter the FBI’s Washington headquarters and turn it into a "deep state” museum and amplifying a meme celebrating violence against Trump critics.

In his book "Government Gangsters," which Trump called a "blueprint to take back the White House,” Patel endorsed calls to fire government employees who undermine the president’s agenda.

"Mark my words, this Patel guy will come back to haunt you,” said Sen. Sheldon Whitehouse, a Rhode Island Democrat, on Feb. 13. "Every piece of evidence shows that and it is not Democrat evidence. It’s his own words, it’s his own colleagues and it’s judges evaluating his credibility.”

Patel sought to distance himself from past controversies during his Senate hearing. He denied he has an enemies list, even though he identified dozens of people in his book that he claimed were part of the deep state.

"I have no interest, no desire and will not, if confirmed, go backwards,” Patel said. "There will be no politicization at the FBI. There will be no retributive actions taken.”

Patel testified last month that the issue of "utmost importance” to him, is "protecting the rights of the Constitution.”

The FBI, one of the most prominent divisions of the Justice Department, is headquartered in Washington in a building named for former director J. Edgar Hoover. The bureau has more than 50 field offices across the country that investigate some of the most complex cases ranging from white-collar crime to cyberattacks, murder and allegations of sexual misconduct.

Key Senate Republicans came to his defense, including Senate Judiciary Committee Chairman Chuck Grassley of Iowa.

"The FBI has been infected by politicization, and this storied agency has been weaponized against political opponents,” Grassley said on Feb. 18. "Mr. Patel’s the right man at the right time. His career has been a study in fighting for unpopular but righteous causes, exposing corruption and putting America first.”

Patel rose to prominence expressing outrage over the FBI’s investigation into whether Trump’s campaign conspired with Russia to interfere in the 2016 presidential election.

In Trump’s first administration, Patel held a number of stopgap national security positions, including chief of staff to Acting Defense Secretary Christopher Miller in the final months of Trump’s White House term. He also served as senior director for counterterrorism at the National Security Council and as a senior adviser to former Acting Director of National Intelligence Richard Grenell.

Patel said that he would resign as a director of Trump Media and Technology Group, the parent company of Truth Social. He said he never accepted compensation from the company, in written responses to questions from Congress. Patel added that he would not accept a stock grant from the company to avoid the appearance of conflict — the grant awarded in late January was worth about $800,000.

Following his confirmation, Patel stepped down from his role on the Trump Media board, where he was replaced by former Interior Secretary David Bernhardt.