One Democrat, Joe Manchin of West Virginia, joined Republicans in voting to confirm Sessions. Sessions himself voted present.
The debate had been intensified by Sessions’ nomination to a federal judgeship three decades ago, which was rejected 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.
In his farewell address Wednesday evening, Sessions urged his erstwhile colleagues to get along better following days of bruising debate.
President Trump has accused Democrats of obstructing the confirmation process, though the Senate will turn next to votes on the president’s picks to lead the health and treasury departments.
At his hearing last month, Sessions said he had never harbored racial animus and claimed he had been falsely caricatured.