The Senate confirmed Todd Blanche as attorney general in a vote early Saturday morning, cementing President Donald Trump’s former personal attorney’s command of a Justice Department the Republican president has sought to bend to his will.

The Republican-led Senate voted 50-49 to make Blanche the second confirmed attorney general since Trump returned to the White House last year with a stated desire to use the law enforcement agency to investigate his political enemies. While Blanche has already been leading the department in an acting capacity, his confirmation could free him to pursue the Trump administration’s agenda even more aggressively.

Blanche said on social media that he was “deeply honored by the trust and confidence President Trump has placed in me,” adding that he was “grateful” to senators for working late to confirm him.

The vote followed a tumultuous confirmation fight that exposed deep concerns — from some Republicans as well as Democrats — about installing Trump’s close ally atop a Justice Department that historically prided itself on its independence from the White House.

In the end, Blanche was confirmed by the narrowest of margins, opposed by two Republicans — Sens. Susan Collins of Maine and Lisa Murkowski of Alaska — and by every Democrat.