Nov. 15 (UPI) — For the first time, the Pentagon will pay for gender-reassignment surgery for an active-duty soldier because doctors deemed the procedure medically necessary, a department spokeswoman said.

Pentagon spokeswoman Dana White said the infantry soldier underwent the surgery Tuesday at a private Pennsylvania hospital. Military hospitals do not have the expertise to conduct this type of procedure.

“Because this servicemember had already begun a sex-reassignment course of treatment, and the treating doctor deemed this surgery medically necessary, a waiver was approved by the director of the Defense Health Agency,” White said. “The Supplemental Health Care Program will cover this surgery in accordance with the Department’s interim guidance on transgender servicemembers.”

The soldier, who identifies as a woman, got her Combat Infantry Badge in Operation Anaconda in Afghanistan in 2003, a source close to the solider told NBC News.

In August, President Donald Trump signed a directive to prohibit people who identify as transgender from serving in the armed forces. His order also prevented the Department of Defense from using federal funds to provide medical treatment like sex-reassignment surgeries and medications.

“In my judgment, the previous administration failed to identify a sufficient basis to conclude that terminating the departments’ 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’s memo read.

Last month, though, a federal court partly blocked the order while a lawsuit against it works its way through the courts.

Washington, D.C., District Judge Colleen Kollar-Kotelly said a group of transgender military members are likely to win their suit against the Trump administration and lifted part of the ban pending the results of the case.

The ruling left the ban on medical treatments in place, but the soldier’s surgery was approved under a waiver due to its medical necessity.

A study by the Palm Center in August found the cost to replace the transgender troops banned by the Trump order would cost $960 million, many times more than the $8.4 million it costs annually for gender transition healthcare.