As Donald Trump flailed his arms and railed against the media at a raucous campaign rally on Saturday night, a Pulitzer prize-winning historian delivered an elegantly scathing rebuke at the White House Correspondents’ Association (WHCA) annual dinner.

America the split screen nation – so evident in polarised reactions to special counsel Robert Mueller’s report on Russian election interference – was on vivid display again in two speeches.

In Green Bay, Wisconsin, the US president raged that journalists are “fakers”, exulted in crowd chants of “CNN sucks!” and lavished praise on Sarah Sanders, his press secretary caught by Mueller lying to the media.

In Washington, Chernow, biographer of founding father Alexander Hamilton and former president Ulysses S Grant, delivered an eloquent and erudite defence of the freedom of the press with some subtle barbs, winning a standing ovation from an audience that quickly forgot any disappointment over the lack of a comedian this year.

Singer Amanda Palmer gestures with her ukulele on the red carpet at the annual White House Correspondents’ Association Dinner in Washington. Photograph: James Lawler Duggan/Reuters

“We now have to fight hard for basic truths that we once took for granted,” said Chernow, who mentioned Trump by name only once in an address that framed the current presidency as just one chapter in America’s epic novel.

He told how the first president, George Washington, often felt maligned and misunderstood by the press but never generalised that into a vendetta. “Relations between presidents and the press are inevitably tough, almost always adversarial, but they don’t need to be steeped in venom.”

The second president, John Adams, used laws to crack down on the media and lost his re-election campaign in 1800, Chernow continued. “Campaigns against the press don’t get your face carved into the rocks of Mount Rushmore, for when you chip away at the press, you chip away at our democracy. The tribunal of history does not deal leniently with presidents who punish the free press.”

Chernow insisted that, while America has taken some wrong turns throughout history, democracy has endured. He told how, towards the end of the civil war, a chastened but hopeful Abraham Lincoln, sitting at a campfire with Grant, quoted his secretary of state William Seward as saying: “There was always just enough virtue in this republic to save it; sometimes none to spare, but still enough to meet the emergency.”

He went on: “Like Lincoln, I believe devoutly in that saving remnant of grace in our country. We’ve fought horrific wars, weathered massive depressions and ended the unspeakable cruelty of slavery and Jim Crow. America has always been at its greatest not when it boasted, not when it blustered, but when it admitted its mistakes and sought to overcome them.”

Chernow, whose book about Hamilton inspired Lin-Manuel Miranda’s hit Broadway musical, said the best presidents have handled the press with “wit, grace, charm, candour and even humour … Whether Republicans or Democrats, we are all bona fide members of Team USA and not members of enemy camps.”

In a rallying call to journalists, the guest speaker said: “Donald J Trump is not the first and won’t be the last American president to create jitters about the first amendment. So be humble, be sceptical and beware of being infected by the very things you’re fighting against.”

From Ida B Wells exposing the horrors of lynching to Bob Woodward and Carl Bernstein reporting on Watergate, he said, “this is a glorious tradition, you are folks are part of it and we can’t have politicians trampling on it with impunity”.

Guests in the ballroom at the Washington Hilton hotel rose to their feet, clapping and cheering. Chernow joked: “I’m sorry to report I’m not finished!”

The historian made clear his distaste for the Trump administration’s embrace of “alternative facts” and false narratives. “Without the facts we cannot have an honest disagreement. I applaud any president who aspires to the Nobel prize for peace, but we don’t want one in the running for the Nobel prize for fiction.”

Trump has refused to attend the WHCA dinner during his time in office and has called the media “enemies of the people”. This year he also banned White House staff from attending, although former press secretary Sean Spicer and longtime friend Chris Ruddy were present.

This was a contrast from a year ago when Sanders looked on uncomfortably from the top table as comedian Michelle Wolf savaged her in a risque routine that stunned organisers and some felt was unduly harsh.

Back in Green Bay, amid a sea of red “Make America great again” caps and chants of “Lock her up!”, Trump invited “the great” Sanders on to the stage to say a few words. As the crowd roared, she said: “Last year this night I was at a slightly different event. Not quite the best welcome. So this is an amazing honour. I’m so proud to work for the president.”

Trump replied that Sanders is “becoming too popular” and, in a nod to his signature reality TV line, joked: “I’m telling you, Sarah, you’re fired!”

In the past the WHCA dinner traditionally hosted both the US president and a comedian who roasted him. The latter group has included Stephen Colbert, Al Franken, Jay Leno, Conan O’Brien and Jon Stewart. But Chernow proved no slouch when it came to gags.

Referring to a recent incident in which Trump reportedly wondered why George Washington did not name his Mount Vernon estate after himself for posterity, he said: “Now as best I can tell, Washington committed only one major blunder as president: he failed to put his name on Mount Vernon and thereby bungled an early opportunity at branding. Clearly deficient in the art of the deal, the poor man had to settle at the lowly title of ‘father of his country’. A very sad story.”

And Chernow ended on a high note. “As we head into election season, I leave you with one last gem: ‘Politicians and diapers must be changed often and for the same reason.’” [See footnote]

Another standing ovation suggested he had won over what is a famously difficult audience. Daniel Mulhall, the Irish ambassador to the US, described the speech as “brilliant”.

• This article was amended on 30 April 2019. In an earlier version, we quoted Chernow attributing the “politicians and diapers” joke to Mark Twain, though studies have suggested this is unlikely.