In apparent response to the criticism, Mr Trump posted a series of tweets in which he said Mr Mattis was "the world's most overrated general".
"I didn't like his "leadership" style or much else about him, and many others agree," he said. "Glad he is gone!"
What did Mattis say?
"Donald Trump is the first president in my lifetime who does not try to unite the American people - does not even pretend to try," Mr Mattis wrote in The Atlantic. "Instead, he tries to divide us."
He continued: "We are witnessing the consequences of three years of this deliberate effort. We are witnessing the consequences of three years without mature leadership."
Mr Mattis also addressed the recent wave of anti-racism protests that were triggered by the death of African-American George Floyd in police custody earlier this month.
"The protests are defined by tens of thousands of people of conscience who are insisting that we live up to our values... as a nation," Mr Mattis wrote. "We must not be distracted by a small number of lawbreakers."
The retired general - whose resignation letter in December 2018 was full of implied criticism of the president's foreign policy - also condemned the use of the military in response to the protests.
"Never did I dream that troops... would be ordered under any circumstance to violate the Constitutional rights of their fellow citizens," he said.
"Militarising our response, as we witnessed in Washington DC, sets up a conflict... between the military and civilian society," he added.
More on George Floyd's death
Earlier this week, peaceful protesters were dispersed with tear gas and rubber bullets from a park close to the White House.
Mr Trump then crossed the park for a photo-op at a historic church that had been damaged by fire in the unrest.
This website or its third-party tools use cookies, which are necessary for analytics and its functioning and required to achieve the purposes illustrated in the cookie policy, including the personalization and analysis of ads and content. If you want to learn more or withdraw your consent to all or some of the cookies, please refer to the cookie policy.
By clicking on Accept you are agreeing to the placement of cookies on your device.
Further use of our site shall be considered as consent. You may view our Privacy Policy and Cookie Policy here for more information.
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Strictly Necessary Cookies
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.