The Senate confirmed Todd Blanche as attorney general early Saturday morning, narrowly elevating President Trump’s former personal attorney to the nation’s top law enforcement post after a rocky confirmation fight that nearly cost him crucial Republican votes.

The vote was 50-49.

Blanche, who was confirmed along party lines as deputy attorney general in March of last year, ran into considerably more resistance from Republicans as he sought the promotion.

At the center of the fight was his decision to approve a $1.776 billion “anti-weaponization” fund expected to funnel money to Trump allies and Jan. 6 defendants.

The fund grew out of an agreement to settle a $10 billion lawsuit Trump brought against the Internal Revenue Service. Blanche formally rescinded it earlier this week after coming under pressure from Republican senators whose votes he needed for confirmation.

But the move did not win over Sens. Susan Collins (R-Maine) and Lisa Murkowski (R-Alaska), who both questioned whether Blanche could operate independently from a president he previously represented as a personal attorney.

Instead, Blanche got across the finish line with the reluctant backing of Sen. Bill Cassidy (R-La.), who announced his decision on the Senate floor Friday morning.

“The choice is not between perfection and Mr. Blanche; it is between Mr. Blanch and another acting attorney general, who may not run the department effectively under President Trump, and who indeed may not be as good as Mr. Blanche,” Cassidy said.

Cassidy made clear that his vote should not be mistaken for an endorsement of everything Blanche has done at the Justice Department.

“Mr. Blanche showed poor judgment in approving the anti-weaponization slush fund and exempting the president from IRS audits. No American should be unfairly targeted by the law, but no American should be above the law,” he said.

Cassidy’s support spared Republicans what could have been a significant delay in getting Blanche confirmed. Without his vote, the Senate may have needed to wait for the return of Sen. Mitch McConnell (R-Ky.), whose intentions on the nomination were unclear.

Blanche faced unusually stiff resistance from Republicans throughout the process.

A Senate Judiciary Committee vote on his nomination had to be postponed after GOP Sens. John Cornyn of Texas and Thom Tillis of North Carolina vowed to oppose him unless he put in writing his pledge that the anti-weaponization fund was “not moving forward. Period.”

After days of haggling, Blanche did so.

The written pledge, however, does not prevent Trump from going to court in an effort to revive the matter. It also does not undo a separate order giving Trump, his adult children and their businesses broad immunity from government review of past conduct, including outstanding tax audits.

Those issues proved too much for Collins and Murkowski.

“The country needs an Attorney General who will check the worst impulses of this administration. I hope Mr. Blanche is able to achieve that, if confirmed, but I simply do not have confidence that will be the case,” Murkowski wrote Friday in announcing her opposition.

Murkowski also took aim at the nearly $2 billion fund and questioned whether its demise would prove permanent once Blanche no longer needed senators’ votes.

“I am also keenly aware that the Department’s nearly $2-billion dollar slush fund—which likely would have rewarded January 6 protesters—is only off the table because this nomination is pending and the Senate has leverage. Once we vote, that will end, and there is no telling what the future holds,” she wrote.

Collins announced earlier this week that she would also oppose Blanche.

While calling him “a capable lawyer,” Collins said the Justice Department “has become increasingly political.”

“Mr. Blanche has taken several actions that have further eroded the Department’s independence, and that is the basis for my vote to oppose his confirmation,” she said.

Collins pointed to Blanche’s pledge to restrict abortion medication as well as the order shielding Trump and his adult children from investigations into their past actions, including failure to pay taxes.

The Justice Department has not yet asserted the rescission of the anti-weaponization fund in the multiple related court cases it faces. Trump, meanwhile, has appealed a ruling in his IRS case that found his lawsuit was collusive in nature.

Blanche also came under pressure over the Justice Department’s efforts to investigate six Democratic lawmakers who appeared in a video telling members of the military that they have the right to refuse illegal orders.

The issue was a major concern for Cassidy, though his floor remarks Friday suggested Blanche had agreed to drop at least some investigations that had drawn public attention.

“I will note that I’ve learned that some of the cases that have been publicly reported to be under investigation by the Department of Justice have been dismissed or are no longer being pursued. I am realistic that President Trump can be unrelenting on this, but this will be true no matter who the Attorney General is, and this is the rationale for having a Senate confirmed Attorney General with more leverage to push back,” Cassidy said.

Democrats had their own lengthy list of complaints about Blanche, ranging from his handling of the Epstein files to cases brought against Trump’s political foes.

Several accused him of lying under oath.

Sen. Mazie Hirono (D-Hawaii) said Blanche testified that he had rescinded the controversial order, only for the publicly released rescission to show that it was signed Sunday.

“He testified that he had rescinded it. In questions for the record, I asked him, ‘Give me the date of when you rescinded this order and this fund.’ He did not answer the question with a date. He refused to end this fund in writing until he was forced into it in order to secure needed votes from my Republican colleagues,” Hirono said Tuesday.

Sen. Adam Schiff (D-Calif.) argued Blanche had never separated himself from his previous role representing Trump.

“We should not confirm an attorney general who views his job as enriching the president of the United States….We should not confirm an attorney general who believes that the president has a right and a duty to go after his political enemies,” Schiff said earlier this week as the Judiciary Committee considered the nomination.

“The problem with confirming Todd Blanch is that he has never been able to shed his role as criminal defense lawyer for Donald Trump. He just can’t do it. He does not represent the American people now. He will never represent the American people. He will never do what’s best for the American people. He will only do what’s best for Donald Trump, and you cannot leave someone like that as the nation’s number one law enforcement official.”

Democrats also pointed to widespread firings at the Justice Department, including employees who worked on Jan. 6 cases, as well as the demotion of other key attorneys.

Blanche faced opposition from outside the Senate as well.

Justice Connection, a DOJ alumni group, sent a letter signed by 1,200 former employees urging senators to reject his nomination.

“Unlike most nominees who come before the Senate, Todd Blanche has spent four months as DOJ’s top dog and a year as second-in-charge. He’s used that time to shred DOJ’s institutional norms, destroy important offices, revictimize sex crime survivors, eviscerate accountability for January 6, attack the career workforce. By serving as the president’s sword and shield, he’s unraveled the rule of law – leaving our rights, economic interests, safety, and democracy on shaky ground,” Stacey Young, a former DOJ official and the group’s executive director, said in a statement.

“Nearly 20,000 career employees have left the department, many of whom were fired or forced out for doing their jobs. This is a generational loss of institutional knowledge and expertise that will be impossible to replace. Today’s vote is an affront to the dedicated public servants still there, as they struggle to uphold the law under a leader who doesn’t.”

The opposition ultimately fell one vote short of blocking Blanche, leaving him to take over the Justice Department after one of the more difficult confirmation fights among Trump’s nominees.