WASHINGTON – President Donald Trump announced Thursday that Defense Secretary Jim Mattis would leave the Pentagon at the end of February.

The announcement came amid the two butting heads on the removal of U.S. troops from Syria, a key policy the president announced on Twitter Wednesday. The president said Mattis, 68, was retiring, but a letter from Mattis shows he resigned so the president could have a defense secretary "whose views are better aligned with yours."

In his resignation letter, Mattis also took a swipe at a tweet posted by the president on Thursday in which he defended his decision to withdraw 2,000 troops from Syria. America, Trump tweeted, should not act as the world’s "policeman."

“Like you, I have said from the beginning that the armed forces of the United States should not be the policeman of the world,” Mattis wrote. “Instead, we must use all the tools of American power to provide for the common defense, including providing effective leadership to our alliances.”

Read the full letter here:

More:Defense Secretary Jim Mattis leaving his job after clash with Trump over Syria

Contributing: Tom Vanden Brook