Joe Arpaio's illegal-immigration crackdown made him a polarizing figure and an early ally of President Trump. (Meg Kelly/The Washington Post)

A federal judge on Thursday shot down former sheriff Joe Arpaio’s bid to sweep his criminal record clean.

Arpaio, the controversial former lawman in Arizona’s Maricopa County, was granted a pardon by President Trump on Aug. 25. He had been found guilty of criminal contempt of a federal court order after a five-day bench trial earlier this year and faced the possibility of up to six months in jail. After the pardon, the 85-year-old Arpaio petitioned the court to clear his record and prevent the ruling from being used in future litigation.

The case raised the novel question of how far a presidential pardon actually reaches.

In her ruling, U.S. District Judge Susan R. Bolton said the pardon only freed Arpaio from possible punishment. In a four-page order offering a check on the president’s executive power, Bolton wrote that a pardon could not erase the facts of the case.

“The power to pardon is an executive prerogative of mercy, not of judicial recordkeeping,” Bolton wrote in the decision. “To vacate all rulings in this case would run afoul of this important distinction. The Court found Defendant guilty of criminal contempt.”

The president issued the pardon, and Arpaio was spared “from any punishment that might otherwise have been imposed,” the judge wrote. “It did not, however, ‘revise the historical facts’ of this case.”

Arpaio’s attorney immediately filed a notice of appeal with the U.S. Court of Appeals for the 9th Circuit.

Arpaio’s hard-line stance on immigration and his harsh treatment of prisoners in Arizona’s Maricopa County made him a household name. Dubbed “America’s toughest sheriff,” it also earned him fans on the political right, as The Washington Post’s Derek Hawkins has written.

The former lawman’s conviction stems from his failure to comply with a 2011 court order halting the detention of individuals on the basis of their suspected immigration status. Arpaio, a vehement proponent of stronger border control, was a vocal backer of Trump’s presidential campaign.

Trump issued the pardon before Arpaio’s sentencing.

Arpaio, who was voted out of office last fall after a 24-year run, said after his pardon that he was thinking about reentering politics. “I think I’ve got a big political message to get out,” he told the Arizona Republic.

Presidential pardons typically forgive a person for a federal crime, but do not retroactively scrub the record of the crime from the court system. But the former sheriff’s attorneys argued that because of the timing, the ruling in the case should be thrown out. Although the move had no technical significance for Arpaio’s situation, his attorneys told The Washington Post in September it would be a “matter of clearing his name.”

The Department of Justice concurred, filing a brief with the court arguing that due to the pardon “the court should vacate all orders and dismiss the case as moot.”

Two groups — Free Speech for People, and the Roderick & Solange MacArthur Justice Center — filed their own motions challenging the pardon itself.

“If the President may employ his pardon power to relieve government officers of accountability and risk of penalty for defying injunctions imposed to enforce constitutional rights, that action will permanently impair the courts’ authority and ability to protect those inalienable rights,” the Free Speech for People brief argued. “The result would be an executive branch freed from the judicial scrutiny required to assure compliance with the dictates of the Bill of Rights and other constitutional safeguards.”

“We are not aware of a single case in our nation’s history where the president pardoned an elected official for disobeying a court order to stop violating constitutional rights,” Ron Fein, legal director at Free Speech for People, told the Intercept in September. “With this pardon, Trump has pushed our country into uncharted territory.”

Read the ruling

More from Morning Mix:

Retired ‘Navy SEAL’ praising Trump on Fox News was a fake

Megyn Kelly tries dancing for ratings as her ‘Today’ show continues to falter

Texas town makes hurricane aid applicants pledge not to boycott Israel

Los Angeles Police Department investigating Harvey Weinstein for alleged 2013 sexual assault

Lupita Nyong’o describes ‘secretly dealing with harassment’ by Harvey Weinstein: ‘I felt unsafe’