Jim Mattis, the former defense secretary, departed from his usual reticence about President Trump and mocked his former boss in a speech on Thursday night that made fun of his bone spur diagnosisduring the Vietnam War and his love for fast food.
The president had recently referred to Mr. Mattis, a retired four-star Marine general, as “the world’s most overrated general.” Mr. Mattis picked up the reference and ran with it for several minutes after being introduced as the keynote speaker at the Alfred E. Smith Memorial Foundation Dinner, an annual charity event in New York where politicians and other leaders typically roast one another.
“I’m not just an overrated general,” Mr. Mattis said. “I’m the greatest, the world’s most overrated,” he said, to laughter and applause.
Turning to address Senator Chuck Schumer, Democrat of New York, Mr. Mattis said he “owed” thanks to New York and to Mr. Schumer for bringing up the general’s name during the “contentious” meeting where Mr. Trump called him “overrated.”
In that meeting at the White House on Wednesday, attended by congressional leaders of both parties, Mr. Trump denigrated Mr. Mattis’s approach to combating terrorism in the Middle East. The general resigned last year as secretary of defense in protest of the president’s decision to pull American troops out of Syria.
Mr. Mattis was “the world’s most overrated general,” Mr. Trump told the group. “You know why? He wasn’t tough enough. I captured ISIS. Mattis said it would take two years. I captured them in one month.”
Mr. Mattis said during the speech on Thursday, “I’m honored to be considered that by Donald Trump, because he also called Meryl Streep an overrated actress.”
“So I guess I’m the Meryl Streep of generals,” he said. “And frankly, that sounds pretty good to me.”
“And you do have to admit that between me and Meryl, at least we have had some victories,” he added.
Mr. Mattis went on, saying that people had asked him during the reception before the dinner whether the “overrated” description had bothered him.
“Of course not,” he said in his speech. “I have earned my spurs on the battlefield.”
He added: “Donald Trump earned his spurs in a letter from a doctor.”
The annual dinner is traditionally a Friars Club-style roast where prominent figures take jabs at one another in a white-tie setting where tickets cost more than $1,000.
Mr. Mattis also referred to earlier remarks by the actor Martin Short, who was the master of ceremonies at the dinner, setting up a punch line.
“The only person in the military Mr. Trump does not feel is overrated,” Mr. Mattis said. “That’s Colonel Sanders,” the founder and symbol of Kentucky Fried Chicken.
Although Mr. Mattis’s remarks were made in a lighthearted setting, they were a departure from his apparent reluctance to comment on the president’s actions.
Many noted the contrast between Mr. Mattis’s comedic delivery and the sober questions raised by another high-profile retired commander, Adm. William H. McRaven, who wrote an opinion piece for The New York Times that was published the same day.
If Mr. Trump “ doesn’t demonstrate the leadership that America needs, both domestically and abroad, then it is time for a new person in the Oval Office — Republican, Democrat or independent — the sooner, the better,” wrote Admiral McRaven, the man who oversaw the raid that killed Osama bin Laden in 2011. “The fate of our Republic depends upon it.”
Before he resigned in December, Mr. Mattis told friends and aides repeatedly that he viewed his responsibility to protect the United States’ 1.3 million active-duty troops as worth the concessions necessary as defense secretary to a mercurial president, The New York Times reported at the time.
“My views on treating allies with respect and also being cleareyed about both malign actors and strategic competitors are strongly held,” Mr. Mattis wrote in his resignation letter. “Because you have the right to have a Secretary of Defense whose views are better aligned with yours on these and other subjects, I believe it is right for me to step down from my position.”
Mr. Mattis devoted much of his Thursday speech, which lasted for nearly 17 minutes, to describing political mistrust in the country, the debt owed to those who have fought for liberty — “among them the American men and women supporting our Kurdish allies” — and the work it takes to maintain a democracy.
“Meanwhile, the roster of urgent national issues have continued to grow,” he said. “Unaddressed, and given the paralysis, impossible to address, and all of this was approaching a level of crisis even before the specter of impeachment arose.”
“This is the moment for an act of remembrance,” he said. “Remembrance of the core principles we used to know and live by, and that we now seem to have forgotten.”