On Saturday night, President Trump was not having the sort of evening he prefers. For starters, he was dressed in white-tie finery, not the golf-ready khakis he favors on weekends. He was surrounded by the very members of the mainstream media he routinely derides. And rather than his beloved Fox News, his entertainment was skits and musical acts, some of which poked fun at him.

Nothing about Trump’s attendance at the annual dinner of the Gridiron Club, an elite group of 65 top Washington journalists, made a lot of sense. But there he was at the Renaissance Washington hotel, accompanied by the first lady, for the club’s 133rd annual gathering, doing something he hardly ever does: observing the traditions that come along with the presidency, particularly the ones that involve performing social rituals.

Presidents since William McKinley, after all, have dutifully shown up at the Gridiron’s formal clambake, which has evolved into an evening of goofy entertainment by the journalists and jokey monologues by a prominent Republican and Democrat, and a mildly roast-y speech by the president.

Trump gamely turned some of the controversies plaguing his administration into laugh (or maybe cringe?) lines. Of the turmoil roiling the White House staff, he offered this quip: “So many people have been leaving the White House,” he said. “It’s invigorating, since you want turnover. I like chaos. It really is good. Who’s going to be the next to leave? Steve Miller, or Melania?” (Miller is one of his senior advisers; Melania, of course, is his wife.) Ba-dum-dum.

He joked about Jeff Sessions, his attorney general, with whom he’s been locked into a public feud over Sessions’s decision to recuse himself from the investigation into Russian influence in the 2016 election. Trump told the crowd that he’d offered Sessions a ride to the dinner, “but he recused himself.”

The relationship between President Trump and Attorney General Jeff Sessions has deteriorated in recent months. Here’s a look at how they got to this point. (Taylor Turner/The Washington Post)

(Full disclosure: The dinner is mostly closed to the working press, so we’re relying here on prepared remarks, pool reports of the president’s remarks and spies inside the room — c’mon, it’s a room full of journalists!)

Trump’s joke about meeting with North Korea was another close-to-the-bone quip. He mused that the country’s supreme leader, Kim Jong Un, faced “the risk of dealing with a madman” if such a confab occurred. Um, ha-ha?

He returned to the other usual subjects of his ridicule, including former vice president Joe Biden (of a possible 2020 campaign matchup with the Delaware Democrat, Trump said “I would kick his a– like no other”); Sen. Elizabeth Warren (D-Mass.), whom he again referred to as “Pocahontas,” and top House Democrat Nancy Pelosi (Calif.), whom he derided as “crazy but a fine woman.”

But Trump found himself on the other end of the ribbing, too. Skits by Gridiron members included Fox News host Bret Baier making cracks about the Russia probe, singing to the tune of “You Can’t Hurry Love” with lyrics that included, “But how many Russians did the campaign meet?/ Don Jr. in Trump Tower, about ‘adoption’ — sure.”

Trump, unsurprisingly, seemed to particularly enjoy the skits that took aim at his enemies. A dinner guest noted that the president got a good chuckle out of a song performed by CBS News’s John Dickerson about president Barack Obama’s luxurious post-White House life (set to the tune of “King of the Road”).

Other speakers also had some barbs for Trump. Looking to find common ground with the president, New Orleans Mayor Mitch Landrieu, a Democrat, observed that “we’re both a little overweight and balding — I just have had an easier time admitting it.”

Landrieu also took aim at Trump’s Cabinet — and in the tradition of these kinds of everyone’s-fair-game speeches, a fellow Democrat. “I feel kinda out of place here,” the Big Easy mayor said. “More out of place than Mike Pence at a men’s figure skating competition. More out of place than Hillary Clinton in Wisconsin. More out of place than the Mnuchins in a Waffle House. More out of place than Jeff Sessions at the Department of Justice. More out of place than John Kelly. Period.”

Other than the journalists, whom the president has identified as “enemies of the state,” there were friendlier faces in the crowd of about 660, including Treasury Secretary Steven Mnuchin, Commerce Secretary Wilbur Ross and Sessions (though Sessions might be considered a Trump frenemy at the moment, with reports circulating that the president has been referring to his top cop as “Mr. Magoo”).

Trump’s daughter Ivanka Trump and her husband, Jared Kushner, both top White House advisers, were there, as were White House press secretary Sarah Huckabee Sanders and  National Security Agency Director Michael S. Rogers. Also in the audience? Rod J. Rosenstein, the Justice Department official who’s overseeing the Russia probe that the president has taken to calling a “witch hunt.”

Trump’s previous forays into comedy haven’t been terribly successful. At the Alfred E. Smith Memorial Foundation Dinner in New York in 2016, he veered from the typical routine of self-deprecation and good-natured barbs and went after his rival and fellow attendee Hillary Clinton, calling her “corrupt.”

He skipped the 2017 White House Correspondents’ Association dinner, which has a similar format. Trump was apparently convinced he would perform well, author Michael Wolff wrote in his book “Fire and Fury,” but his staff was “terrified that he would die up there in front of a seething and contemptuous audience. Though he could dish it out, often very harshly, no one thought he could take it.”

CORRECTION: An earlier version of this article misstated the year in which President Trump did not attend the White House Correspondents’ Association dinner.