The Senate on Wednesday confirmed Sen. Jeff Sessions to be attorney general in the Trump administration despite fierce Democratic opposition to the Alabama Republican over his record on civil rights and immigration.

The 52-47 nearly party-line vote capped weeks of divisive battles over Sessions, an early supporter of President Donald Trump and one of the Senate’s most conservative lawmakers. After the vote was announced, Sessions’ Republican colleagues applauded the outcome while barely a handful of Democrats did the same.

Epitomizing the sharp-edged partisanship surrounding confirmation of Trump’s Cabinet nominees, Sen. Elizabeth Warren was given a rare rebuke Tuesday evening for quoting Coretta Scott King, widow of the late civil rights leader Martin Luther King Jr., in her 1986 criticism of Sessions.

King wrote that as an acting federal prosecutor in Alabama, Sessions used his power to “chill the free exercise of the vote by Black citizens.”

Senate Majority Leader Mitch McConnell held that the Massachusetts Democrat had run afoul of rules about impugning a fellow senator.

Rashad Robinson, executive director of Color of Changed issued a statement, sharply criticizing the vote. “In voting to confirm [Sessions], each one of these Senators is rubber stamping this White House’s racist, right wing agenda to steal our rights, our freedoms, and our country,” Robinson said. “They have voted to sell off the legacy of the civil rights movement.”

Sessions’ nomination to a federal judgeship was rejected three decades ago by the Senate Judiciary Committee after it was alleged that as a federal prosecutor he had called a black attorney “boy” and had said organizations like the NAACP and the American Civil Liberties Union were un-American.

At his hearing last month, Sessions said he had never harbored racial animus, saying he had been falsely caricatured.

Democrats laced into Sessions, casting him as too cozy with Trump and too harsh on immigrants. They asserted he wouldn’t do enough to protect voting rights of minorities, protections for gays and the legal right of women to obtain an abortion. They fear immigrants in the country illegally won’t receive due process with Session as the top law enforcement officer.

“Any attorney general must be able to stand firm for the rule of law even against the powerful executive that nominated him or her. In this administration I believe that independence is even more necessary,” said Sen. Tim Kaine, D-Va. “His (Sessions’) record raises doubts about whether he can be a champion for those who need this office most and it also raises doubts about whether he can curb unlawful overreach” by Trump.

Republicans say Sessions has demonstrated over a long career in public service — and two decades in the Senate — that he possesses integrity, honesty and is committed to justice.

“He’s honest. He’s fair. He’s been a friend to many of us, on both sides of the aisle,” Majority Leader Mitch McConnell, R-Ky., said. “It’s been tough to watch all this good man has been put through in recent weeks. This is a well-qualified colleague with a deep reverence for the law. He believes strongly in the equal application of it to everyone.”

Sessions won unanimous backing from Senate Republicans but picked up the support of just one Democrat, Joe Manchin of West Virginia.