President Donald Trump announced Wednesday he is banning transgender individuals from serving in the military “in any capacity” — a surprise announcement that is sure to draw condemnation from LGBTQ groups.

“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,” Trump tweeted shortly after 9 a.m.

“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,” Trump added. “Thank you.”

The announcement comes after the House failed to pass an amendment that would ban transgender individuals in the military from having their medical costs related to their transitions funded by military health care plans.

The House voted down that amendment on July 14, with Republicans joining Democrats to tank the proposal.

Rep. Vicky Hartzler (R-Mo.), the author of the amendment, called funding transgender servicemembers’ treatment a “misuse of our precious defense dollars” in a statement, according to Politico.

During his time in office, now-former President Barack Obama created a policy that allowed the Department of Defense to pay for transgender reassignment surgery and other treatments related to transitioning.

Trump’s decision to ban transgender individuals from serving in the military seemed to come as a surprise to the Pentagon, which referred all questions about the policy to the White House.

But in a statement, a Pentagon official said the military will “continue to work closely with the White House to address the new guidance provided by the commander-in-chief on transgender individuals serving the military.”

“We will provide revised guidance to the department in the near future,” Navy Capt. Jeff Davis said in a statement, according to the Hill.

A Trump administration official told Axios’ Jonathan Swan, however, that the decision was political in nature, meant to force Democrats to defend the rights of transgender Americans in the 2018 midterm elections.

“This forces Democrats in Rust Belt states like Ohio, Michigan and Wisconsin to take complete ownership of this issue,” the unnamed Trump official told Swan. “How will the blue collar voters in these states respond when senators up for re-election in 2018 like Debbie Stabenow are forced to make their opposition to this a key plank of their campaigns?”

Country rock singer Kid Rock is mulling a challenge to Stabenow in Michigan.

Trump, for his part, said during the 2016 presidential campaign that he would be better for the LGBT communities than Hillary Clinton.

“Thank you to the LGBT community! I will fight for you while Hillary brings in more people that will threaten your freedoms and beliefs,” Trump tweeted in June 2016.

July 26, 2017, 10:42 a.m.: This article has been updated.