But the highlight of the night always comes when the journalists offer the stage to the president for some self-deprecating jokes and good-natured roasting.

For Mr. Trump, who has spent a lifetime flouting political correctness, his participation in the dinner was striking because the club is the Washington embodiment of political correctness. Its credo is that the roasts at the dinner should “singe but never burn.”

This year, Mr. Trump leaned into the flame.

He took aim at his favorite target: “Fake News CNN.” He called Fox News the “fourth branch of government.” And he made fun of Arthur Ochs Sulzberger Jr., who stepped down in December as publisher of The New York Times, saying: “I inherited millions. Arthur inherited billions of dollars, and he turned it into millions.”

The president also poked fun at Stephen K. Bannon, his former chief strategist, who many inside the White House believe was the source for some of the nastiest parts of the recent book by Michael Wolff.

Mr. Bannon, the president said, “leaked more than the Titanic.”

And he directed a jab at himself over his infatuation with the size of his inauguration crowd, claiming credit for all the crowds at the recently completed Winter Olympics in South Korea.

The relationship between any president and the press is fraught. But it is especially true for Mr. Trump, who spent his first year in the Oval Office in a near constant state of agitation about what he views as a media that is unfair and plotting against him.