WASHINGTON -- President Trump engaged in a good-natured duel of one-liners with political rivals and the press at the annual Gridiron Dinner this weekend, largely putting aside his ongoing criticism of the media for a night.

Mr. Trump dished out sharp one-liners throughout his comments Saturday night, occasionally lapsing into recurring themes about the 2016 election and media bias.

"Nobody does self-deprecating humor better than I do. It's not even close," said Mr. Trump, who skipped last year's dinner. He also said: "I was very excited to receive this invitation and ruin your evening in person. That's why I accepted."

Get Breaking News Delivered to Your Inbox

The annual dinner of the Gridiron Club and Foundation, now in its 133rd year, traced its history to 1885, the year President Grover Cleveland refused to attend. Every president since has come to at least one Gridiron.

"Rest assured, Mr. President, this crowd is way bigger than Cleveland's," Club President David Lightman, congressional editor for McClatchy News, told the white-tie audience at the Renaissance Washington Hotel. The organization said the event attracted about 660 journalists, media executives, lawmakers, administration officials and military officers.

Members of the Washington press corps sharpened their wits for musical and rhetorical takedowns of the president, Hillary Clinton, Barack Obama. Mr. Trump's speech lasted more than a half hour and included plenty of one-liners.

A sampling:

On his son-in-law: "We were late tonight because Jared could not get through security."

On Vice President Mike Pence: "He is one of the best straight men you're ever going to meet ... he is straight. Man." Mr. Trump also said, "I really am proud to call him the apprentice." Mr. Trump joked that Pence wakes up every day and asks "Is he impeached yet?"

On Attorney General Jeff Sessions: "I offered him a ride over and he recused himself. What are you going to do?"

On The New York Times: "I'm a New York icon. You're a New York icon. And the only difference is I still own my buildings."

On former chief strategist Steve Bannon: "That guy leaked more than the Titanic."

On the first lady: Mr. Trump said he doesn't understand why everyone says #freemelania. He said she's actually having a great time.

Toward the end of his comments, Mr. Trump couldn't resist some of his favorite themes, revisiting his election night victory and chiding reporters to be fair.

He closed by saying: "I just want to say this, this is one of the best times I've had with the media -- this might be the most fun I've had since watching your faces on election night."

He recalled the close race in Michigan, saying the media wouldn't call it for him, even though he had a good margin of victory. And he accused some reporters of not being impartial in their coverage.

For much of the night he was a good sport -- laughing and applauding at times during the evening's entertainment. Hours earlier, Mr. Trump had fired off a sharp tweet at the national press:

"Mainstream Media in U.S. is being mocked all over the world. They've gone CRAZY!" He linked to a story by a conservative pundit saying Mr. Trump and his family are victims of "unparalleled" press attacks.

The major political parties found themselves skewered in parody songs in musical skits. By Gridiron tradition, comments came from one Republican, Sen. Tom Cotton of Arkansas, and one Democrat, New Orleans Mayor Mitch Landrieu.

Cotton made light of what he called the source of his personality: the common touch of Harvard, the sensitivity of the Army, and the personal touch of Dick Cheney. On the Russia investigation, he said, "Everyone knows the Trump campaign couldn't collude with the RNC in Pennsylvania." The only senator in his 30s says he's looking for a role model and "the search continues."

With an eye on the president, Landrieu said: "We're both overweight and balding. I just have an easier time admitting it." Noting that Mr. Trump had a lonely job, the mayor remarked, "I understand lonely because I'm a Democrat from the South." The New Orleans official also observed, "No matter how many times we say it, we don't drain the swamps either."

The Gridiron Dinner's reputation as a night of bipartisan mirth was evidenced by those who accepted invitations, including last year's headliner, Vice President Pence. Also accepting invitations were at least eight members of Mr. Trump's Cabinet, six senators, four House members, and presidential relatives-turned-advisers Ivanka Trump and Jared Kushner, the foundation said in a statement.

By tradition, the evening's musical entertainment revolved around musical skits and takeoffs of well-known songs performed by journalists pretending to be newsmakers.

A cast member playing House Democratic leader Nancy Pelosi turned to "I'm Against It," a song from the Marx Brothers film "Duck Soup," to explain her attitude toward Mr. Trump: "I don't know what Trump has to say/It makes no difference anyway/Whatever it is, we're against it/Even if our own side once professed it/We're against it."

A cast member playing Hillary Clinton offered her version of the song "You're So Vain," the title referring to her, but the lyrics aimed at the president: "You walked into my West Wing/My White House or so I thought/Your tie strategically dropped below your belt/Your hair it was apricot."

A charitable organization, the Gridiron Club and Foundation contributes to college scholarships and journalistic organizations. Active membership is limited to 65 Washington-based journalists.

Mr. Trump wrapped up the evening on an upbeat note.

"I want to thank the press for all you do to support and sustain our democracy," he said in closing.