It was President Trump’s ­revenge on the nerds.

The president spoke directly to his fans at a rally 2¹/₂ hours from Washington, DC, on Saturday night — at the same time that the annual White House Correspondents’ Dinner he spurned was under way.

Minutes into his address, he taunted the press, saying, “a large group of Hollywood actors and Washington media are consoling each other in a hotel ballroom in our nation’s capital right now.”

Instead of noshing on steak, halibut, and grilled asparagus with media elites, Trump dragged reporters away from their black-tie gala to cover his address in Harrisburg, Pa., marking his 100th day in office.

“I could not possibly be more thrilled than to be more than 100 miles away from the Washington swamp spending my evening with all of you and with a much larger crowd and much better people,” he added.

Trump touted his record while slamming reporters as “incompetent, dishonest people.” He said the press should also be judged for its performance in the past 100 days.

“If the media’s job is to be honest and tell the truth, then I think we would all agree the media deserves a very, very big fat failing grade,” he said.

Reporters clinking wine glasses at the Washington Hilton bristled at the remarks.

“We are not fake news, we are not failing news organizations, and we are not the enemy of the American people,” Reuters’s Jeff Mason said in an address to the gathering.

Trump decided in February to skip the swanky affair — the first commander-in-chief to do so since Ronald Reagan, who remained at Camp David in 1981 recuperating from a bullet wound.

Still, Reagan delivered remarks by phone, joking, “If I could give you just one little bit of advice, when somebody tells you to get in a car quick, do it.”

Holding a rally instead of hobnobbing with journalists also sent a message to reporters that he does not need them, politicos said.

“He doesn’t respect the press, and they think he’s a buffoon and a charlatan,” said Democratic political consultant Dan Gerstein.

After Trump nixed his correspondents’ dinner invite, his staff boycotted the fete in solidarity. Trump reportedly does not like the choice of emcee, “Daily Show” comedian Hasan Minhaj.

Organizers asked Minhaj to not make fun of Trump, but that did not sway the president, Page Six reported Friday.

Minhaj ignored the correspondents’ request. He broiled Trump for much of the evening while defending free speech.

“Only in America can a first-generation Indian-American Muslim kid get on this stage and make fun of the president, the orange man behind the Muslim ban,” he said. “This shows the entire world that even the president is not beyond the reach of the first amendment.”

He quipped, “In four hours Donald Trump will be tweeting about how bad Nicki Minaj bombed at this dinner and he’ll be doing it completely sober. And that’s his right,” Minhaj added.

At Saturday’s rally, Trump said he would consider attending the dinner in 2018 to “make it more exciting for them.”

But “if they want him to go they’ll have to get the right comedian next year,” said former Trump adviser Sam Nunberg.