Democrats, immigrant rights activists and other members of the anti-Trump resistance were enraged by President Trump’s pardon late Friday of former Maricopa County Sheriff Joe Arpaio.

And so was Sen. John McCain.

While most Republicans remained silent on the pardon, Mr. McCain, an Arizona Republican who has frequently battled both Mr. Arpaio and Mr. Trump, released a statement saying the president had undercut his own proclamations of law and order.

“Mr. Arpaio was found guilty of criminal contempt for continuing to illegally profile Latinos living in Arizona based on their perceived immigration status in violation of a judge’s orders,” said Mr. McCain. “The president has the authority to make this pardon, but doing so at this time undermines his claim for the respect of rule of law as Mr. Arpaio has shown no remorse for his actions.”

Mr. Trump made Mr. Arpaio his first pardon — and in keeping with the tenor of the young presidency, sparked a massive controversy.

Some blasted the president for acting on a Friday night, just as a massive hurricane was barreling down on Texas, saying he appeared to be trying to hide his actions.

If that’s true, it failed.

Cable television and the internet lit up with the news, which even bled into websites devoted to sports or entertainment.

The White House, in a statement, said the pardon was recompense for Mr. Arpaio’s life of public service.

The White House did not discuss the facts of the case against Mr. Arpaio, which stemmed from a policy he implemented as a six-term sheriff, using traffic stops to try to spot illegal immigrants in his county, then turn them over to federal authorities for deportation.

A federal judge appeared to order the sheriff to halt the policy in 2011, finding it an unconstitutional act of racial profiling. But federal prosecutors said the sheriff’s department continued the practice.

Mr. Arpaio was convicted earlier this year by another federal judge of criminal contempt.

The former sheriff’s legal team was already seeking to have the conviction vacated or overturned, saying Mr. Arpaio should have been given the right to a jury trial, and that the judge cherry-picked testimony, ignoring those parts they said showed the lawman had not been explicitly told to halt the traffic stops.

Democrats said that to use the pardon power on someone newly convicted in a prosecution his own justice department oversaw was an odd step for the president.

“It is a shame to see the pardon power devalued like this. The ex-sheriff is a self-aggrandizing braggart who promoted racist law enforcement practices and cost taxpayers millions, and that is a reason they did not reelect him.

“Nobody believed the president when he said he would be the ‘Law and Order’ president and he has proven us all right,” said Rep. Luis V. Gutierrez, Illinois Democrat.

Mr. Gutierrez said that by choosing to pardon a man involved in racial profiling cemented views that Mr. Trump is catering to racists.

Immigrant-rights groups also blasted Mr. Trump, saying the pardon upended the laws all Americans must abide by.

“Pardoning Joe Arpaio diminishes the very concept of law and order,” said Ali Noorani, executive director of the National Immigration Forum, who ticked off a list of transgressions by the former lawman, including racial profiling, defying the judge’s order and failing to investigate sex crimes.

“Moments like these are when we must ask ourselves what kind of country we want to live in: one that turns a blind eye on law and order, or one where we unite under our shared values to respect the humanity of immigrants,” Mr. Noorani said.

Mr. Arpaio lost his bid for a seventh term in last year’s elections, after immigrant-rights groups poured manpower into Arizona to rally against him.

“Trump’s pardon of Arpaio is an official endorsement on racial profiling and the abuse of immigrants and people of color. It is also a slap in the face of the people in Maricopa County who voted a racist, anti-immigrant sheriff out of his job,” said Cristina Jimenez, executive director of United We Dream, an advocacy group for illegal immigrant Dreamers.