"I'm honored to be considered that by Donald Trump because he also called Meryl Streep an overrated actress," he said. "So I guess I'm the Meryl Streep of generals, and frankly that sounds pretty good to me."

Trump lashed out at his former defense secretary Wednesday, during a contentious White House meeting with members of Congress.

The meeting was intended to be a bipartisan discussion of Trump's decision to pull U.S. forces from northern Syria, but it broke up after a testy exchange between Trump and House Speaker Nancy Pelosi.

Before the walkout, Trump disparaged Mattis, who had argued as defense secretary that U.S. troops were needed in Syria to prevent a resurgence of Islamic State fighters.

Trump said Mattis was "the world's most overrated general. You know why? He wasn't tough enough."

"I captured ISIS," Trump went on to say.

Mattis resigned as defense secretary last December after Trump said he intended to pull 2,000 American troops out of Syria. In his resignation letter, the retired Marine general told Trump he had "the right to have a Secretary of Defense whose views are better aligned with yours."

Since then, he has largely refrained from publicly criticizing the administration, saying he owed the commander in chief "a duty of silence."

But he did save a zinger for Trump at the laughter-filled gala, saying the "overrated" moniker didn't bother him.

"I earned my spurs on the battlefield ... and Donald Trump earned his spurs in a letter from a doctor," Mattis joked.

On a serious note, Mattis alluded to Trump's decision to have U.S. troops stand down in Syria, clearing the way for Turkey to launch an offensive against Kurdish forces who had been U.S. allies in the fight against the Islamic State group. On Thursday, the U.S. and Turkey agreed to a five-day cease-fire that requires the Kurdish fighters to vacate, largely solidifying Turkey's position in the region.

"We owe a debt to all who fought for liberty, including those who tonight serve in the far corners of our planet, among them the American men and women supporting our Kurdish allies," Mattis said.

The annual gala draws luminaries from finance and politics. Hosted by Cardinal Timothy Dolan, the archbishop of New York, the benefit is named after a former New York governor who was the first Catholic to receive a major party nomination for president in 1928, before losing the general election.