Facing a near-universal backlash over his decisions to pull U.S. troops from Syria and cut in half the number of forces in Afghanistan, President Trump late Saturday night unloaded on two outgoing officials who resigned over those decisions, saying he gave Defense Secretary James Mattis “a second chance” after the retired Marine Corps general was fired by former President Obama.

In a series of tweets, Mr. Trump also took aim at Brett McGurk, the administration’s special envoy to the global anti-Islamic State coalition.

Last Wednesday, the president abruptly announced that the U.S. had defeated the Islamic State in Syria and that the roughly 2,000 American troops stationed there would be coming home. The surprise declaration sparked the resignation of Mr. Mattis. Mr. McGurk had been scheduled to leave in February but sped up his departure over the policy decision.

Just days before the president announced the Syria withdrawal, Mr. McGurk had stated flatly that the U.S. had a long-term interest in keeping troops in Syria, and that the administration knew it could not just defeat the Islamic State’s “physical space” and then leave.

“Brett McGurk, who I do not know, was appointed by President Obama in 2015,” the president said. “Was supposed to leave in February but he just resigned prior to leaving. Grandstander? The Fake News is making such a big deal about this nothing event!”

The president has clearly been irked by the negative reaction to his troop withdrawal announcements. Leading Republicans on Capitol Hill and many conservative pundits have panned the moves, especially after Mr. Mattisresigned in protest last Thursday.

Mr. Trump argued Sunday that he should be considered a “hero” for having the courage to bring U.S. forces home.

“If anybody but your favorite President, Donald J. Trump, announced that, after decimating ISIS in Syria, we were going to bring our troops back home (happy & healthy), that person would be the most popular hero in America,” he tweeted. “With me, hit hard instead by the Fake News Media. Crazy!”

Regarding Mr. Mattis, the president said he essentially resurrected the Defense secretary’s career by nominating him to lead the Pentagon. Formerly the commander of U.S. Central Command, Mr. Mattis was fired from that post by Mr. Obama in 2013. He reportedly clashed with Obama administration officials over Iran policy and was seen as too much of a foreign policy hawk

“When President Obama ingloriously fired Jim Mattis, I gave him a second chance. Some thought I shouldn’t, I thought I should,” Mr. Trump said. “Interesting relationship-but I also gave all of the resources that he never really had. Allies are very important — but not when they take advantage of U.S.”

In his resignation letter, Mr. Mattis made clear that he disagrees sharply with Mr. Trump’s foreign policy views. Particularly on SyriaMr. Mattis believes the president is now abandoning key U.S. allies at a critical time in the fight against the Islamic State and is sending the wrong signal to the rest of the world.

“While the U.S. remains the indispensable nation in the free world, we cannot protect our interests or serve that role effectively without maintaining strong alliances and showing respect to those allies,” he said in the 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.”