Donald Trump
Donald Trump

Donald J. Trump began this quadrennial exercise in campaign humility and self-deprecation on Thursday by comparing himself to the son of God — just another “carpenter working for his father” in his youth.

Donald Trump
Donald Trump

By the end, facing cascading and uncomfortable jeers from a crowd full of white ties and gowns, he had called Hillary Clinton Catholic-hating, “so corrupt” and potentially jail-bound in a prospective Trump administration.

“I don’t know who they’re angry at, Hillary, you or I,” Mr. Trump said sheepishly from the dais, turning to his opponent amid the heckling.

It seemed clear to everyone else. Mr. Trump was being booed at a charity dinner.

Sign Up For NYT Now’s Morning Briefing Newsletter 

So it went at the Alfred E. Smith Memorial Foundation Dinner in Manhattan, a presidential campaign ritual of levity and feigned warmth — upended, like so much else in this election season, by the gale-force bid of Mr. Trump.

Breaking with decades of tradition at the gathering once he took the microphone, Mr. Trump set off on a blistering, grievance-filled performance that translated poorly to the staid setting, stunning many of the well-heeled guests who had filed into the Waldorf Astoria hotel for an uncommon spectacle: an attempted détente in a campaign so caustic that the candidates, less than 24 hours earlier, declined to shake hands on a debate stage.

Relations did not much improve.

Mr. Trump’s set began typically enough. He joked about the size of his hands and Mrs. Clinton’s comparatively small crowds. He even very nearly poked fun at himself — insofar as a zinger about his wife, and her partly plagiarized Republican convention speech, qualifies — when discussing the “biased” news media.

“You want the proof? Michelle Obama gives a speech, and everyone loves it,” Mr. Trump said. “My wife, Melania, gives the exact same speech and people get on her case.”

Some sharper jokes about Mrs. Clinton seemed to edge just to the line.

“Just before taking the dais, Hillary accidentally bumped into me. And she very civilly said, ‘Pardon me,’” Mr. Trump said, as murmurs filled the room. “I very politely replied, ‘Let me talk to you about that after I get into office.’”

Mrs. Clinton, seeming to get the joke before some others, bellowed before the punch line.

But quickly, his remarks took a more menacing turn.

Mr. Trump said Mrs. Clinton was merely “pretending not to hate Catholics,” an allusion to hacked correspondences from Clinton aides that appeared to include messages criticizing Roman Catholic conservatism.

He wondered aloud how someone like Mrs. Clinton — “so corrupt,” he said — could sell herself to the American people. “What’s her pitch?” he asked. “The economy is busted, the government’s corrupt, Washington is failing. Vote for me.”

He fake-griped that “all the jokes were given to her in advance.”

He appeared to disparage the Clinton Foundation’s oft-criticized efforts in Haiti.

“As some of you have noticed, Hillary isn’t laughing as much as the rest of us,” he said.

By then, he had decisively lost the room.

As for Mrs. Clinton, she began with some easy self-deprecation.

“I took a break from my rigorous nap schedule to be here,” she said, adding, “Usually, I charge a lot for speeches like this.”

But she quickly turned to more cutting satire, joking that Mr. Trump was “translating from the original Russian” on his teleprompters and wondering just how President Obama might be able to visit the White House for a reunion of former presidents under a Trump administration.

“How is Barack going to get past the Muslim ban?” she asked.

She also spoke of the Statue of Liberty, recounting how for most Americans, the green lady of freedom represents a shining beacon of hope and a welcome symbol for immigrants arriving on the nation shores. But Mr. Trump, she added with a glint of steel, “looks at the Statue of Liberty and sees a 4” — a not-so-veiled reference to his comments rating the physical appearance of women.

“Maybe a 5 if she loses the torch and tablet and changes her hair,” she continued, before making an explicit, if subtle, pitch for becoming the nation’s first female president.

“You know, come to think, know what would be a good number for a woman? 45,” she concluded triumphantly.

At the dinner before the remarks, the pair could be seen chatting, at least briefly, seated two seats apart, with only Cardinal Timothy M. Dolan, the archbishop of New York, between them. (Perhaps only a man of God could, for a night, soothe a campaign that has included an F.B.I. inquiry, overnight Twitter binges, multiple accusations of sexual misconduct and an international feud between the Republican nominee and Pope Francis).

Before the candidates spoke, Alfred E. Smith IV, the chairman of the dinner, which benefits Catholic charities, seemed to offer a preview of what may await Mr. Trump as he tries to return to New York society life should he not win the White House in November.

“Before the dinner started, Trump went to Hillary and asked, ‘How are you?’” Mr. Smith said, waiting a beat. “She said, ‘I’m fine — now get out of the ladies’ dressing room.’”

Even under the best of circumstances, Mr. Trump is not known for an eagerness to laugh at himself. A veritable roasting at Washington’s annual “nerd prom,” the White House Correspondents’ Association’s annual dinner, in 2011 may have hastened — or even catalyzed — his bid for the Oval Office. And now a flagging presidential campaign — most polls place him several percentage points behind Mrs. Clinton nationally — has done little to help.

Then there was the guest list. In addition to Mrs. Clinton, Mr. Trump was surrounded on the dais by assorted adversaries from his political and professional life. Michael R. Bloomberg, the billionaire former New York City mayor who has vocally opposed Mr. Trump’s bid, was perched in the first row, just in front of the candidates. And Eric T. Schneiderman, the New York attorney general, whose office has opened an investigation into Mr. Trump’s foundation, was positioned a safe distance away in the back.

At least one Trump ally, former Mayor Rudolph W. Giuliani, did attend what is, during even typical election seasons, a quintessentially New York event, packed with local political leaders and power brokers.

This year, it so happens that two New Yorkers can also be found at the top of the ballot.

One seemed to have more fun on Thursday than the other. Mr. Trump sat with his arms tightly folded as Mrs. Clinton spoke, a similarly taut smile across his face. But when Mrs. Clinton returned to one his favorite themes — her health — he seemed momentarily buoyed.

Mr. Trump, Mrs. Clinton said, had chivalrously sent a car to ferry her to the dinner. “Actually, it was a hearse,” she said.

Finally, Mr. Trump laughed with real joy.