WASHINGTON — The Defense Department has approved a new policy that will largely bar transgender troops and military recruits from transitioning to another sex, and require most individuals to serve in their birth gender.

The memo outlining the new policy was obtained Tuesday by The Associated Press, and it comes after a lengthy and complicated legal battle. It falls short of the all-out transgender ban that was initially ordered by President Donald Trump. But it will likely force the military to eventually discharge transgender individuals who need hormone treatments or surgery and can’t or won’t serve in their birth gender.

The order says the military services must implement the new policy in 30 days, giving some individuals a short window of time to qualify for gender transition if needed. And it allows service secretaries to waive the policy on a case-by-case basis.

Under the new rules, currently serving transgender troops and anyone who has signed an enlistment contract by April 12 may continue with plans for hormone treatments and gender transition if they have been diagnosed with gender dysphoria.

But after April 12, no one with gender dysphoria who is taking hormones or has transitioned to another gender will be allowed to enlist. And any currently serving troops diagnosed with gender dysphoria after April 12 will have to serve in their birth gender and will be barred from taking hormones or getting transition surgery.

Transgender troops tell Congress they excel in military Transgender troops testifying for the first time to Congress on Wednesday said transitioning to another sex made them stronger, while Pentagon officials defended the Trump administration’s desire to bar people like them from enlisting in the future.

The memo lays out guidelines for discharging service members based on the new policy. It says a service member can be discharged based on a diagnosis of gender dysphoria if he or she is "unable or unwilling to adhere to all applicable standards, including the standards associated with his or her biological sex, or seeks transition to another gender."

It adds that troops must be formally counseled and given a chance to change their decision before the discharge is finalized.

× Fear of missing out? Sign up for the Early Bird Brief - a daily roundup of military and defense news stories from around the globe. Thanks for signing up. By giving us your email, you are opting in to the Early Bird Brief.

Palm Center, a California research institute, protested the new policy Tuesday. Director Aaron Belkin said, "The Trump administration is determined to bring back 'don't ask, don't tell,' a policy that forced service members to choose between serving their country and telling the truth about who they were."

The final legal injunction blocking the new policy was lifted last week, allowing the Pentagon to move forward. But restrictions on transgender troops are likely to face ongoing legal challenges and have been slammed by members of Congress as discriminatory and self-defeating.

The memo was signed by David L. Norquist, who is currently serving as the deputy defense secretary.

Rep. Jackie Speier, D-Calif., said in February that barring service by transgender individuals “would cost us recruits at a time when so few Americans are willing to serve.” She spoke at a hearing in which transgender troops testified that transitioning to another sex made them stronger and more effective members of the military.

Until a few years ago, service members could be discharged from the military for being transgender, but that changed under the Obama administration. Then-Defense Secretary Ash Carter announced in 2016 that transgender people already serving in the military would be allowed to serve openly. And the military set July 1, 2017, as the date when transgender individuals would be allowed to enlist.

After Trump took office, however, his administration delayed the enlistment date and called for additional study to determine if allowing transgender individuals to serve would affect military readiness or effectiveness.

A few weeks later, Trump caught military leaders by surprise, tweeting that the government won't accept or allow transgender individuals to serve "in any capacity" in the military. "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 wrote.

His demand for a ban triggered a legal and moral quagmire, as the Pentagon faced the prospect of throwing out service members who had willingly come forward as transgender after being promised they would be protected and allowed to serve. And as legal battles blocked the ban from taking effect, the Obama-era policy continued and transgender individuals were allowed to begin enlisting in the military a little more than a year ago.

Lawmakers aim to reverse Trump’s ban on transgender troops Supporters call the president's ban on new transgender military recruits unfair and harmful to national security.

An estimated 14,700 troops on active duty and in the Reserves identify as transgender, but not all seek treatment. Since July 2016, more than 1,500 service members were diagnosed with gender dysphoria; as of Feb. 1, there were 1,071 currently serving. According to the Pentagon, the department has spent about $8 million on transgender care since 2016. The military's annual health care budget tops $50 billion.

Last year, all four service chiefs told Congress that they had seen no discipline, morale or unit readiness problems with transgender troops serving openly in the military. But they also acknowledged that some commanders were spending a lot of time with transgender individuals who were working through medical requirements and other transition issues.

The five transgender troops who testified in February said their medical transitions took anywhere from four weeks to four months and they did most of it on their own time. All said they were fit to return to deploying afterward.