Former Maricopa County Sheriff Joe Arpaio, front right, leaves U.S. District Court on the first day of his contempt-of-court trial Monday, June 26, 2017, in Phoenix. (Ross D. Franklin/AP)

A federal judge dismissed the criminal case against Joe Arpaio on Wednesday and upheld President Trump's power to pardon the controversial former Arizona sheriff — although she left uncertain, for now, whether his conviction and other orders in the case will be vacated, according to Arpaio's defense attorney and other people involved in the case.

Jack Wilenchik, an attorney for Arpaio, said U.S. District Judge Susan R. Bolton in Arizona rejected challenges to the pardon filed by outside groups and indicated that it was valid. Wilenchik said Bolton dismissed the case but did not immediately rule on a request to vacate all the orders in it, including Arpaio's conviction.

Arpaio, 85, considers that step important to clearing his name, and it could have repercussions in civil lawsuits, Wilenchik said.

[Joe Arpaio has been pardoned. But will a judge dismiss the verdict against him?]

In July, Bolton found Arpaio guilty of criminal contempt for ignoring another judge's order to stop detaining people because he merely suspected them of being undocumented immigrants. He had yet to be sentenced.

Arpaio had long been a controversial figure for his extreme views on immigration and for his forcing inmates to wear pink underwear and sleep outdoors in his Tent City jail. But he found an ally in Trump, on whose behalf he spoke at the Republican National Convention.

As the case against Arpaio headed toward trial, Trump had asked Attorney General Jeff Sessions whether it would be possible to drop the matter. Advised that that option was not tenable, the president opted instead to pardon the former Maricopa County sheriff after his conviction.

"He's done a great job for the people of Arizona, he's very strong on borders, very strong on illegal immigration, he is loved in Arizona," Trump said at the time. "I thought he was treated unbelievably unfairly when they came down with their big decision to go get him, right before the election voting started."

Arpaio, who was first elected sheriff in 1993, was voted out of office in November.

Most pardons are granted long after the recipients are convicted or sentenced, putting Arpaio in a somewhat atypical position. Pardons generally serve to forgive people, rather than to erase what they have done, and the Justice Department notes in guidance on its website that pardons do not remove convictions from a person's criminal record.

But Arpaio had asserted his innocence and vowed to appeal. He asked the judge to thus vacate all her findings in the case — arguing that he would not be able to clear his name through the normal court process, nor would it be practical to do so.

"Because the President issued a pardon before sentencing and judgment — and clearly, before the conclusion of any appeals — the Court is obligated to vacate its verdict and all other orders in this matter, and to dismiss the case with prejudice," Arpaio's attorneys wrote. "Because Defendant will never have the benefit or opportunity to seek a reversal of the court's verdict through appeal (and a retrial by jury), it is only fair that the Court vacate its verdict and all other rulings in the case."

The Justice Department agreed with Arpaio's position, but several Democratic lawmakers and outside groups and legal scholars asked to intervene in the case, arguing that the pardon was unconstitutional and the guilty finding should not be vacated.

Ian Bassin, executive director of the Protect Democracy Project, which had argued that the pardon was unconstitutional, said the judge felt bound by a 1925 Supreme Court case which affirmed the president's pardon power, but the decision was not an easy one.

"I think if the president continues to abuse his pardon power, you are likely to see courts take a very hard look at whether that century-old case got it wrong," he said.