President Donald Trump late Friday followed up on his surprise Twitter announcement and issued an order barring transgender people from joining the U.S. military, while leaving the fate of those already in uniform up to his cabinet.

The ban will continue beyond Jan. 1 of next year, Trump wrote in his memo, until his cabinet convinces him to do otherwise. The president is also prohibiting government-funded sex-reassignment surgery for troops, “except to the extent necessary to protect the health of an individual who has already begun a course of treatment to reassign his or her sex.”

In issuing his memo, Trump took aim at the Obama administration, which reversed the ban on transgender people openly serving in the U.S. military last year. The government gave the military until this year to start accepting new transgender troops. But Defense Secretary Jim Mattis announced a six-month delay, saying that would give the military time to review whether the change would impact its “readiness and lethality.”

“In my judgment,” Trump wrote, “the previous administration failed to identify a sufficient basis to conclude that terminating the department’s longstanding policy and practice would not hinder military effectiveness and lethality, disrupt unit cohesion, or tax military resources, and there remain meaningful concerns that further study is needed to ensure that continued implementation of last year's policy change would not have those negative effects.”

Trump has also directed his cabinet to decide how to handle transgender people already serving in the military, saying that until that is done “no action may be taken against such individuals under the policy.”

Last month, Trump announced on Twitter that the government would not “accept or allow” transgender people to serve in the U.S. military. As many as 6,630 transgender people are among the nation’s 1.3 million troops, according to a study by the RAND Corp. It’s unknown how many of them are in Georgia, which is home to thousands of U.S. service members and some major military installations, including Fort Benning, Fort Gordon and Fort Stewart.

RELATED: President Trump: No transgender people allowed in the U.S. military

IN-DEPTH: Pentagon weighs allowing transgender troops to serve openly

OutServe-SLDN, a nonprofit group that advocates for transgender people, immediately announced it would sue to challenge Trump’s directive.

"The president’s order to remove transgender service members from the United States armed forces and deny them healthcare is nothing less than a purge,” said OutServe-SLDN Executive Director Matt Thorn. “He is implementing this purge based on bigotry, motivated by agents of an ideology that has no concern for the national defense, and in blatant disregard of the experience of career officers who spent more than a year developing and implementing the current policy.”