President Trump spent 20 minutes during a raucous rally in Phoenix on Tuesday night reframing his response to the violence in Charlottesville by attacking the media — then launched an invective at the state’s two Republican senators and even hinted at pardoning Sheriff Joe Arpaio.

Trump blamed the “crooked media” for backlash he received after claiming “many sides” were responsible for the “Unite the Right” rally that turned deadly when a white supremacist plowed his car into counter-protesters — killing one woman and wounding 19 others.

“They don’t want to report the facts — just like they don’t want to report that I spoke out forcefully against hatred and condemned the white supremacists,” he said of the media. “There were two statements and one news conference.”

Trump never repeated his controversial “many sides” remark Tuesday night, but focused on his condemnation of racist groups two days after the bloodshed.

“There were two statements and one news conference. I hit ‘em with neo-Nazi, I hit ‘em with everything. … KKK? We have KKK. I got ‘em all,” he said. “The words were perfect — and for the most part, all they [the media] do is complain. They don’t put on those words.”

Trump apologized to the crowd for dedicating such an outsize chunk of his nearly 80-minute speech to defending himself.

“I didn’t want to bore you because you understand where I’m coming from,” he told rally-goers.

Trump went on to address two other sensitive areas: his criticism of Arizona’s Republican Sens. John McCain and Jeff Flake, and his plans to pardon Arpaio.

“One vote away, and I will not mention any names — that’s very presidential, isn’t it?” he said, in an apparent reference to McCain, whose vote killed the effort to advance the ObamaCare repeal bill.

“And nobody wants me to talk about your other senator who’s weak on borders, he’s weak on crime,” Trump said in a dig to Flake. “Nobody wants me to talk about him — nobody knows who the hell he is.

“I haven’t mentioned any names, so now everybody’s happy.”

Neither McCain nor Flake attended the rally.

Trump also indicated he would pardon Arpaio — the Maricopa County, Ariz., lawman convicted in July of contempt of court for ignoring a 2011 order that he stop racial profiling in his efforts to combat illegal immigration.

“I’m just curious. Do the people in this room like Sheriff Joe? So was Sheriff Joe convicted for doing his job?” Trump said.

“He should have had a jury, but I’m gonna make a prediction: I think he’s gonna be just fine, okay? But I won’t do it tonight because I don’t want to cause any controversy. Is that all right? Okay. But Sheriff Joe can feel good.”

Trump had previously said he was “seriously considering” pardoning Arpaio, but White House spokeswoman Sarah Huckabee Sanders told reporters Tuesday afternoon that Trump would not bring it up at the rally.

“No action will be taken on that front at any point today,” she said moments before Air Force One touched down in Arizona.

Trump had to deal with hecklers once during his speech.

“How did he get in here?” Trump said after someone interrupted him. “He’s supposed to be with the few people outside.

“All week they were talking about the massive crowds that were supposed to be outside, well, where are they?”

Protests stayed civil in the hours leading up to the rally.

The road outside the Phoenix convention center was barricaded, and supporters and detractors were left shouting at one another from opposite sides of the street. Police with riot helmets stood by in the center, and scuffles were limited.

In one exchange, a Trump supporter and protester shoved each other. In another, the two groups shouted at each other before moving on.

There were no arrests, according to Fox10.

With Post wires