March 13 (UPI) — The Department of Defense has approved a new policy that bars transgender military members from transitioning to another sex.

The policy, sought by President Donald Trump, had to clear legal hurdles before it was signed Tuesday by David Norquist, the No. 2 ranking civilian official in the Pentagon, ABC News reported.

The 15-page policy requires transgender troops to serve in the sex they were assigned at birth and must obtain a waivers to use showers and bathrooms. It also bars troops from receiving treatment like hormone therapy and transgender-related surgeries.

The policy reverses a 2016 Obama administration directive that allowed transgender military personnel for the first time to serve openly.

The ban allows troops who have been treated for gender dysphoria — defined as a condition resulting from distress over a person’s birth gender — to continue serving and receiving treatments. The policy will take effect April 12, after which no troops will be allowed to enlist with those requirements.

The policy also allows branch secretaries to issue waivers on a case-by-case basis.

Last month, five transgender service members told the House Armed Services Committee their gender identity doesn’t impede their ability to meet military responsibilities. It marked the first time Congress had heard testimony from active transgender service members.

The issue was taken to federal court where an appeals court upheld the ban, overturning a lower court injunction. The administration has cited “tremendous medical cost and disruption” as reasons for the ban.

Opponents have attacked the policy change as discriminatory.

“I would like to know what it is that the president is so afraid of?” Rep. Jackie Speier, D-Calif., chair of the House Armed Service Military Personnel subcommittee, asked Tuesday. “Transgender troops have served for decades and carried out multiple deployments, including Afghanistan, Iraq, and Syria, to protect our country and freedoms.”

A 2016 study by think tank RAND found there are fewer than 7,000 transgender troops among more than one million active-duty members. The study, funded by the Pentagon, also found the cost of treating transgender troops and their effect on readiness to fight were negligible.