WASHINGTON (Reuters) - U.S. Defense Secretary Jim Mattis abruptly said he was quitting on Thursday after falling out with President Donald Trump over his foreign policies, including surprise decisions to yank troops from Syria and start planning a drawdown in Afghanistan.

Mattis announced plans to depart in a candid resignation letter to Trump that laid bare the growing divide between them, and implicitly criticized Trump for failing to value America’s closest allies, who fought alongside the United States in both conflicts.

He released the letter after a face-to-face meeting with Trump in which the two men also aired their differences, a senior White House official said.

“Because you have a right to 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,” Mattis said in the letter.

U.S. officials said the resignation had not been forced by Trump.

Trump announced on Wednesday that U.S. troops in Syria would be withdrawn, a decision that upended American policy in the region. On Thursday, an official said the president was planning to withdraw at least 5,000 of the 14,000 U.S. troops in Afghanistan - another blow to Mattis, who advocated for a strong U.S. military presence to bolster diplomatic peace efforts.

Mattis, a retired Marine general whose embrace of NATO and America’s traditional alliances often put him at odds with Trump had advised against the Syria withdrawal. One official said it was a contributing factor to his resignation.

The news is certain to shock U.S. military allies, already bewildered by what they see as Trump’s unpredictable, go-it-alone approach to global security, and raises questions about whether Mattis’ successor will be as steadfast about traditional treaty commitments, including to NATO.

When Mattis interviewed with Trump for the job in 2016, he split with the president-elect on a host of issues, including on NATO and the use of torture. Trump ultimately deferred to Mattis, who opposed the latter, signaling that he could be persuaded by his advisers.

But as time grew, Trump increasingly acted on his own instincts on a host of national security issues, choosing an “America First” agenda that contradicted Mattis’ core beliefs.

Mattis’ letter indicated that he disagreed with Trump’s isolationist policies, writing that it was his belief the United States needed to maintain strong alliances and show allies respect.

Trump has withdrawn the United States from several international agreements since taking office in January 2017.

The Mattis resignation letter also said that he believed the United States “must be resolute and unambiguous in our approach to those countries whose strategic interests are increasingly in tension with ours.” He identified Russia and China as countries that “want to shape a world consistent with their authoritarian model.”

Mattis’ resignation was greeted with regret on Capitol Hill, by both Republicans and Democrats.

U.S. Senate Majority Leader Mitch McConnell indicated he was in agreement with Mattis on America’s alliances and on Russia, whom he described as a foe.

“But I am particularly distressed that he is resigning due to sharp differences with the president on these and other key aspects of America’s global leadership,” McConnell said in a statement.

Senator Bob Menendez, the top Democrat on the Foreign Relations Committee, called it “a significant loss and a real indication that President Trump’s foreign policy agenda has failed and continues to spiral into chaos.”

Slideshow ( 7 images )

WHITE HOUSE UNPREDICTABILITY

The shifts in significant aspects of U.S. foreign policy and Mattis’ addition to the long list of senior Trump administration figures who have quit or been removed added to the sense of an increasingly unpredictable White House as Trump approaches the halfway point of his four-year term.

And if defense policy disagreements were not enough distraction for a president who is under investigation by a special counsel over Russian interference in the 2016 U.S. election, financial markets took a beating this week and a U.S. government shutdown loomed because of funding disputes over Trump’s desire to build a wall on the U.S.-Mexico border.

This year has been the worst for world stock markets since the 2008 global financial crisis, with MSCI’s 47-country world stocks index down 10 percent.

Slideshow ( 7 images )

Trump, announcing Mattis’ departure on Twitter, said he would nominate a successor soon.

“General Jim Mattis will be retiring, with distinction, at the end of February, after having served my Administration as Secretary of Defense for the past two years,” he said.

One possible candidate to replace Mattis as defense chief could be Republican Senator Tom Cotton, long considered a front-runner to eventually take the role.

Trump’s White House has had the highest turnover of senior-level staff of the past five presidents, according to the Brookings Institution think tank.

Some departed unceremoniously, such as Trump’s first Secretary of State Rex Tillerson, whom Trump fired via Twitter in March.

Speculation that Mattis might not last long in his post grew in October when Republican Trump said in a CBS interview that the general was “sort of a Democrat” and might be leaving. Mattis responded at the time by telling reporters that he had Trump’s full support.

Stephen Miller, a senior White House adviser, said Trump was entitled to a Pentagon chief with whom he could agree.

“This is an opportunity for the whole country to get a new secretary of defense who will be aligned with the president on these critical issues, whether you’re talking about in Syria, whether you’re talking about across the Middle East in general,” Miller told CNN.