In this July 26, 2017 file photo, people with the Human Rights Campaign hold up "equality flags" during an event on Capitol Hill in Washington, in support of transgender members of the military.

WASHINGTON — A federal judge on Wednesday ordered the Pentagon to turn over thousands of documents that the Defense Department has refused to release to the public but has said it used to justify its decision to ban most transgender people from military service.

U.S. District Judge Marsha Pechman ruled the Pentagon must turn over drafts, communications and documents used by Defense Department officials in shaping and justifying its 48-page policy released in February 2018 that effectively ended open service for transgender men and women. That policy, which faces several legal challenges, went into effect in April, barring the military enlistment of nearly any person with a diagnosis of gender dysphoria, the medical condition associated with individuals who do not identify with their birth sex.

Pentagon officials under President Donald Trump’s administration have long argued that policy does not constitute a blanket ban. Moreover, they have stated publicly that the department gathered specific data during a study of transgender troops that showed their service brought “substantial risks” to the military. Among the concerns raised in the policy, which was informally dubbed “the Mattis plan” for then-Defense Secretary Jim Mattis, were that transgender troops’ medical conditions could “impede readiness, limit deployability and burden the military with additional costs.” But the Defense Department has declined to make any of that data public or describe it in detail, even when pressed by journalists to do so.

Lawyers with Lamda Legal, representing transgender plaintiffs in the case of Karnoski v. Trump in U.S. district court in Seattle, sought the documents as evidence in their case, which seeks to overturn the partial ban on transgender military service on the basis that the policy was rooted in illegal discrimination.

Pentagon lawyers sought to keep the documents private, claiming they were privileged information, and their release could damage the department's ability to hold frank internal deliberations for fear such debate could be released to the public.

Despite Pechman’s order, the data will not be made public immediately, as she limited the documents to “attorneys’ eyes only” in order to avoid a “potential chilling effect upon the future deliberations of government actors,” which Pentagon lawyers argued could occur if the data and other documents related to the case were disclosed.

Peter Perkowski, the legal and policy director of the Modern Military Association of America, a nonprofit organization that supports LGBTQ military members, said he was “thrilled with the court’s decision.” He also said the data would provide needed clarity on the origins of the ban ordered initially by Trump in a series of surprise tweets in July 2017.

“The government cannot conceal the truth about the development of this discriminatory policy and the absence of any justification for excluding qualified transgender people from serving our country,” Peter Renn, a Lambda Legal attorney, said in a prepared statement.

Lawyers for the transgender plaintiffs had sought about 35,000 documents. Pechman wrote in her decision that the Pentagon had agreed to turn them over by Friday.

In August 2017, Mattis ordered the study on military service by transgender servicemembers, which was led by a panel of senior Pentagon officials, after Trump’s order to ban them from serving “in any capacity.” His eventual policy would overturn the Pentagon’s 2015 decision — under former President Barack Obama’s administration — to open service to transgender individuals who were stable in their preferred gender.

The Mattis policy bars from military service almost all people who have been diagnosed with gender dysphoria — described by the American Psychiatric Association as “a conflict between a person’s physical or assigned gender and the gender with which he/she/they identify.” It also bans all people who have medically transitioned their sex.

The former defense secretary’s policy does allow people to enlist with a diagnosis of gender dysphoria who have doctor certification that they have remained stable in their biological sex for 36 months. But those individuals must serve and adhere to the standards of their biological sex and a transition to their preferred gender must not be medically necessary for the servicemember’s treatment of gender dysphoria.

Modern Military Association of America and other LGBTQ groups have blasted the ban, often comparing it to the 1990s-era “Don’t Ask, Don’t Tell” policy that banned open service by gay men and women.

This month, many of those organizations criticized Congress’ decision not to include language overturning the ban in the fiscal year 2020 National Defense Authorization Act, the annual bill that sets Pentagon policy and was passed this week. The NDAA is expected to be signed into law by Trump on Friday.

dickstein.corey@stripes.com

Twitter: @CDicksteinDC