President Trump announced on Wednesday that the United States will no longer “accept or allow” transgender people in the United States military, saying American forces “must be focused on decisive and overwhelming victory” and could not afford to accommodate them.

Mr. Trump made the surprise declaration in a series of posts on Twitter, saying he had come to the decision after talking to generals and military experts, whom he did not name.

“After consultation with my generals and military experts, please be advised that the United States government will not accept or allow transgender individuals to serve in any capacity in the U.S. military,” Mr. Trump wrote.

“Our military must be focused on decisive and overwhelming victory and cannot be burdened with the tremendous medical costs and disruption that transgender in the military would entail,” he added.

The sweeping policy decision was met with surprise at the Pentagon and outrage from advocacy groups. It reverses the gradual transformation of the military under President Barack Obama, whose administration announced last year that transgender people could serve openly in the military. Mr. Obama’s defense secretary, Ashton B. Carter, also opened all combat roles to women and appointed the first openly gay Army secretary.

It was not clear what prompted Mr. Trump’s decision. The Pentagon referred questions about the policy change to the White House, where several officials did not immediately respond to questions about the reasoning and timing behind Mr. Trump’s decision.

But the announcement came amid a debate on Capitol Hill over the Obama-era practice of requiring the Pentagon to pay for medical treatment related to gender transition. The dispute has unfolded as Congress considers a nearly $700 billion spending bill to fund the Pentagon.

Full story at The New York Times.