/ Updated  / Source: Associated Press

The Justice Department is asking a federal court to dismiss a lawsuit challenging President Donald Trump's moves to curtail military service by transgender people.

The lawsuit was filed in August by the National Center for Lesbian Rights and GLBTQ Legal Advocates & Defenders (GLAD) on behalf of eight transgender individuals, including service members in the Air Force, Coast Guard and the Army, as well as students at the U.S. Naval Academy and in the ROTC program at the University of New Haven.

Trump tweeted in July that the federal government "will not accept or allow" transgender individuals to serve "in any capacity" in the military. That would reverse a 2016 policy change that allowed transgender people to serve openly.

Trump subsequently directed the Pentagon to extend indefinitely a ban on transgender individuals joining the military, and gave Defense Secretary Jim Mattis six months to come up with a policy on how to deal with those who are currently serving, leaving the door open to permitting their continued service.

Trump also directed Mattis to halt the use of federal funds to pay for sexual reassignment surgeries and medications, except in cases where it is deemed necessary to protect the health of an individual who has already begun the transition.

Follow NBC OUT on TWITTER, FACEBOOK and INSTAGRAM