Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

PHOENIX, Ariz. — President Donald Trump strongly hinted Tuesday night that he might pardon Sheriff Joe Arpaio, saying Arpaio will be "just fine" despite being found guilty of criminal contempt for violating a court order.

"Do the people in this room like Sheriff Joe?" Trump asked the thousands of supporters gathered here for a campaign-style rally. The crowd erupted into chants of "pardon Joe!"

"Was Sheriff Joe convicted for doing his job?" the president asked. Arpaio is a former Maricopa County, Arizona, law enforcement officer, who ignored a court order to stop detaining suspected undocumented immigrants.

Trump had been rumored to be considering a pardon for Arpaio, an early and outspoken supporter. He told Fox News last weekend he was "seriously considering" a pardon for the former sheriff, a folk hero among conservatives and a lightning rod for critics of his aggressive immigration crackdowns.

But the White House said before Trump's campaign rally that a pardon would not come during Tuesday's event.

"I won't do it tonight," the president told the crowd, adding that he wanted to avoid causing "any controversy."

Maricopa County Sheriff Joe Arpaio announces newly launched program aimed at providing security around schools on January 9, 2013 in Anthem, Arizona. file Laura Segall / Reuters file

Arpaio told NBC News earlier Tuesday the decision not to pardon him in Phoenix was "their decision — right now."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"I've been with him from day one, and I'll always be with him and support him," Arpaio said.

Arpaio served as sheriff for 24 years before losing his re-election bid last November.

A judge ruled last month that the former sheriff had committed a crime by flouting the order not to detain suspected undocumented immigrants. The decision was widely seen as a rebuke of a law enforcement official whose tactics — including housing immigrants in a tent city and forcing detainees to wear pink underwear — had long been divisive.

In 2013, a judge found Arpaio and his deputies had engaged in racial profiling against Latinos, backing up the findings of a 2011 Justice Department report.

Arpaio's sentencing is set to start on Oct. 5. He intends to appeal the verdict.

In a free-wheeling speech that lasted more than an hour, Trump also renewed his offensive against the media, indicting news outlets for giving "a platform to hate groups," blaming journalists for "division in our country," and defending himself by reading to supporters his responses to the rally of white supremacists in Charlottesville, Virginia, last week.

The president said his words at the time were "perfect" — noting that he condemned the KKK and white nationalists — and charged the media's coverage was biased against him, alleging a "double standard" from the coverage President Barack Obama received on race-related issues.

Trump, however, did not mention that he had blamed "both sides" for violence — a comment which drew such widespread criticism at the time.

While critics from both parties suggested Trump's reaction to Charlottesville deepened racial divides in the U.S., Trump instead instructed the crowd that to discover the "source of the division in our country, look no further than the fake news."

"The only people giving a platform to these hate groups is the media itself and the fake news," he added.

A demonstrator taunts police while Trump speaks in Phoenix, Arizona. Sandy Huffaker / Reuters

But Trump's discussion of national issues also took a local turn Tuesday. Though he didn't name names — in what he called a "very presidential" move — he indirectly criticized both Arizona senators, John McCain, who is battling brain cancer, and Jeff Flake, who is facing a tough re-election. Both are Republicans.

After Trump repeatedly lamented that "one vote!" had prevented Republicans from advancing efforts to repeal Obamacare, the crowd chanted "McCain's gotta go!" McCain had opposed the GOP bill.

"And nobody wants me to talk about your other senator," Trump said, moving on to Flake — whom the president called weak on crime and illegal immigration.

Trump also showed a willingness to shut down the government if that's what it takes to get funding for his long-promised border wall with Mexico. "If we have to close our government, we are building that wall," he said, referring to the budget battles that lie ahead as Congress considers whether to spend billions on the wall.

Outside the venue, four protesters were arrested, police said, for offences including aggravated assault and criminal damage.

“They broke down fencing and at one point dispersed gas into and at the officers,” Phoenix Police Chief Jeri Williams told reporters.