Former Defense Secretary Jim Mattis, who has largely shied away from the spotlight since leaving office last December, took aim at President Trump in a speech at the 74th Annual Alfred E. Smith Memorial Foundation Dinner in New York Thursday night. Guests at the dinner usually lampoon politicians, but the mocking tone was a departure for Mattis, who has generally refused to criticize the president's foreign policy actions since leaving office.

"I earned my spurs on the battlefield ... Donald Trump earned his spurs in a letter from a doctor," Mattis joked at one point, in a reference to the medical deferment for bone spurs that kept Mr. Trump from serving in the military during the Vietnam War.

At another point, Mattis responded to reports that Mr. Trump called him "the world's most overrated general" during a meeting with Democrats earlier this week. Mattis joked that he felt like he had "achieved greatness," because he was "not just an overrated general, I am the greatest, the world's most overrated."

Former U.S. Secretary of Defense Jim Mattis, center, delivers the keynote address during the 74th Annual Alfred E. Smith Memorial Foundation Dinner, Thursday, Oct. 17, 2019, in New York. Mary Altaffer / AP

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

Get Breaking News Delivered to Your Inbox

After publishing his book "Call Sign Chaos: Learning to Lead" in August, Mattis was criticized by some for not doing more to condemn Mr. Trump in the book or in subsequent media appearances to promote it. In an interview with NPR in September, Mattis said: "I don't discuss sitting presidents."

Mattis shied away from direct criticism of Mr. Trump's policy decisions during the dinner, including the drawdown of troops in northern Syria, which Turkey saw as an opening to launch an offensive against the Kurds in the reason. Mattis resigned in December because Mr. Trump advocated for total withdrawal of American troops from Syria.

After taking humorous digs at Mr. Trump, Mattis turned to talking about Abraham Lincoln and the political conditions which led to the Civil War, including hyper-partisanship.

Mattis noted that Lincoln believed great nations could fall due to "corrosion from within – the rot, the viciousness, the lassitude, the ignorance."

"Anarchy is one potential consequence of all this. The other is the rise of an ambitious leader, unfettered by conscience, or precedent or decency, who would make himself supreme," Mattis said.

Mattis also alluded to the Kurds in Syria, who were crucial allies in the fight against the terrorist group ISIS. Vice President Mike Pence announced a cease-fire between Turkey and the Kurds on Thursday, which would involve the Kurds completely decamping from Northern Syria.

"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.