Long term, lawyers and activists battling to ensure that transgender people can serve openly in the U.S. military are convinced they will prevail. Short term, they are braced for anguishing consequences if the Trump administration proceeds with its plan to sharply restrict such service.

The U.S. Supreme Court, in a 5-4 vote Tuesday, gave the administration the green light to put the policy into effect even as legal challenges continue.

"I'm absolutely optimistic with respect to the long-term prospects," said Sharon McGowan, legal director of the LGBT rights group Lambda Legal, which is pressing one of the lawsuits. "The question is: How long is the long term?"

McGowan and other activists see parallels between the battle and the 17-year saga involving the "don't ask, don't tell" policy that prohibited gay men and women from serving openly in the armed forces. After prolonged controversy and litigation — as well as the discharge of more than 13,000 military personnel — Congress repealed the Clinton-era policy in 2010, and gay service members were able to serve openly beginning in 2011.

LGBTQ rights activist Andy Blevins, who served in the Navy from 2007 to 2011, said he underwent three investigations related to "don't ask" before he was finally discharged on medical grounds. He is now executive director of OutServe-SLDN, which represents LGBTQ personnel in the military and is engaged in the litigation against the Trump plan.

Blevins grows emotional in describing the "daily struggle" to keep his sexual orientation a secret before repeal of "don't ask," yet he suggested that currently serving transgender people face even tougher circumstances. They were told in 2016, in the waning months of the Obama administration, that they would be able to serve openly, then were jolted in 2017 when President Donald Trump tweeted his intention to ban all transgender people from the military.

"They were told it's OK to be transgender ... then the rug is pulled out from under these dedicated service members," Blevins said.

Yet he said activists have made major progress in convincing politicians and the public that the Trump plan is based on misinformation and prejudice.

"We have optimism that we're going to win the war," he said. "This is just a setback, a speed bump."

The Morning Rundown Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

OutServe-SLDN's legal director, Peter Perkowski, is teaming with Lambda Legal lawyers on one of four lawsuits challenging Trump's plan. Though he shares Blevins' long-term optimism, he is wary of the outcome if any of the lawsuits reach the Supreme Court, now with a solidified conservative majority thanks to the addition of Trump appointees Neil Gorsuch and Brett Kavanaugh.

"There's a certain segment of the court that's kind of hostile to our issues in the LGBTQ community," Perkowski said. "Beyond that, I don't make any predictions."

Meanwhile, Perkowski said, transgender people seeking to enlist are frustrated by legal uncertainties, while currently serving trans personnel are worried about their job security.

"They just want to continue to do their jobs without this cloud hanging over them, without being tagged as inadequate," he said.

Among those active-duty trans service members is Megan Winters, 30, a plaintiff in the Lambda-Outserve lawsuit who has been in the Navy almost six years. She formerly served with the Office of Naval Intelligence in Washington and now is assigned to the aircraft carrier USS George H. W. Bush, based in Norfolk, Virginia.

"I do my job to the best of my ability every single day and will do that as long as I'm able to," she said in a telephone interview. "I recall how I felt the first time I put on the uniform. I genuinely wish that upon any American who wishes to serve."

Asked if Tuesday's Supreme Court vote made her apprehensive, Winters paused before saying it was hard to answer.

"I want to tell you I stand steadfast and hold my head up high — but it is a little difficult," she said. "The president of the United States is my commander in chief. If they called for the end of transgender service, if it's a lawful order I would have to obey it. But I truly want to continue serving my country."

According to a report issued by the Pentagon last year, there were 8,980 service members who identify as transgender.

Details of how the Trump plan might be implemented remain unclear; some currently serving trans personnel — perhaps including Winters — might be able to remain in the military. However, the court vote clears the way for the Pentagon to bar enlistment by people who have undergone a gender transition. It also would allow the administration to require that military personnel serve in accordance with their biological gender unless they began a gender transition under the Obama-era rules.

Activists doubt the current Republican-controlled Senate would move to block the transgender ban. And it would face a potential Trump veto if it did so.

However, Aaron Belkin of the California-based Palm Center, which studies LGBTQ-related military issues, said public opinion now favors transgender military service, and added, "The Democrats will reinstate an inclusive policy on the first day they're back in power."

Supporters of Trump's efforts include Tony Perkins, a Marine veteran who is president of the conservative Family Research Council. He says the courts should not interfere with the ability of the U.S. president as commander in chief to set military policy.

"The Pentagon isn't in the business of equality," Perkins said recently. "Either the military's priority is protecting America — or it's helping people on the path to self-actualization. It can't do both."

But Lambda Legal's McGowan said top military commanders have said there were minimal problems related to the Obama administration's moves to allow transgender service. The Trump policy, she said, "has nothing to do with national security or unit cohesion — it's about throwing red meat to a portion of Trump's political base."

McGowan evoked Katie Schmid, a South Korea-based Army staff sergeant who is a plaintiff in Lambda's lawsuit.

"They're telling Katie, you're unfit to die for this country," McGowan said. "I can't think of a more offensive thing to say to someone willing to put their life on the line."

For LGBTQ rights leaders, Trump's proposed ban is only one of several attacks on transgender Americans. They also cite a Justice Department memo concluding that civil rights laws don't protect transgender people from workplace discrimination and the scrapping of Obama-era guidance encouraging school officials to let transgender students use bathrooms of their choice.

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM