More than 200 flags were given to members of the Air Force’s 354th Fighter Wing and residents of Fairbanks, Alaska, for Pride Month in 2015. (U.S. Air Force photo by Senior Airman Ashley Nicole Taylor)

In late October, the superintendent for a Defense Department school in Germany informed one of her students — the 11-year-old transgender daughter of a service member stationed at Ramstein Air Base — that the child was no longer allowed to use the girls’ restroom.

The student was frightened by the prospect of using the boys’ room, and forced to leave her building and walk across a courtyard to use gender-neutral facilities. Advocates appealed to the Pentagon, calling the superintendent’s action an affront to the girl’s civil rights. It also appeared to be at odds with a policy, approved in June 2016, lifting a prohibition on military service by the thousands of transgender men and women already in uniform and setting a one-year deadline to develop plans for accepting transgender enlistees and officer candidates. Within days, a military-wide directive declared all students free to use school bathrooms and locker rooms consistent with their gender identity.

But the incident in Germany was indicative of a deep institutional resistance to the all-inclusive policy ushered in during the waning months of Barack Obama’s presidency.

And in a series of tweets Wednesday morning, President Trump signaled his intent to ban transgender men and women from serving in the U.S. military, saying their presence in the ranks is costly and distracting.

The Pentagon had no immediate answers on how Trump’s pronouncement will be implemented, saying only that it would work closely with the White House to carry out the commander in chief’s orders. Defense Secretary Jim Mattis is away from Washington on vacation.

For transgender troops and those who’ve supported their inclusion in the ranks, the president’s tweets represent the worst-case scenario they’ve long feared but hoped would never materialize. But the truth is there were indications of a wider rollback months ago.

As Military Times first reported in February, the Pentagon quietly rescinded its schools directive within weeks of Trump’s inauguration and Mattis’s confirmation as defense secretary, marking the first significant departure from Obama-era military personnel policy. It occurred as the Trump administration laid the groundwork to revoke similar protections for transgender students attending public schools, and raised questions about whether Trump and Mattis wanted to change other Obama policies, including those lifting restrictions on LGBT individuals and on women wishing to serve in ground-combat jobs.

Todd Weiler, the assistant defense secretary under Obama who ordered school facilities accessible to transgender students, said that well before Trump became the commander in chief, any effort to promote social change was met with pushback.

“That mind-set from the 1950s and ’60s” is pervasive among the Pentagon’s longest-tenured civilian staff, Weiler said, noting later that the generals and admirals “weren’t signing on in droves” in support of the policy. “They want a return to ‘Leave it to Beaver,’ but that’s not going to work.”

When the schools policy was rescinded after the inauguration, “I thought it was more than likely a slap at me because I tried to help a little girl and didn’t listen to a 30-year careerist,” he said. “I didn’t think it would lead to getting rid of the entire policy.”

Within the working group tasked with writing that policy for Obama’s defense chief, Ashton B. Carter, Pentagon officials struggled to find common ground on how to address living arrangements. As Military Times reported in May, some insisted transgender troops should be required to wear bathing suits while showering in communal facilities.

Yet perhaps the June 2016 plan’s most controversial feature called for American taxpayers to cover the cost for transgender personnel to receive medical care, including reassignment surgeries and hormone treatments. As part of his accession policy, though, Carter’s order made clear that recruits would have to first complete all necessary medical care at their own expense and then have a doctor certify them as “stable in their identified gender” for 18 months.

Troops and military leaders most opposed to the policy derided it as social experimentation and a threat to readiness — the same arguments made when Obama moved to end the “don’t ask, don’t tell” policy precluding military service by openly gay men and women. Those concerns proved unfounded, according to a report compiled by the Palm Center research institute.

During Mattis’s Senate confirmation in January, Democrats challenged the retired Marine general on whether he intended to strip away the rights newly afforded to LGBT troops. He had questioned those changes in the past, once saying, “We have to be very careful that we do not undercut battlefield effectiveness with shortsighted social programs.” But when asked, Mattis told Senate lawmakers that he “never cared much about two consenting adults and who they go to bed with.”

“If someone brings me a problem, I’ll look at,” he said then. “But I’m not coming in looking for problems.”

This spring, as senior military leaders faced a July 1 deadline for implementing the accession policy, two transgender students preparing to graduate from the Army and Air Force military academies learned they would not be allowed to join the active-duty force. The Pentagon explained that Mattis was conducting a “readiness review” to ensure each of the services was fully prepared to bring on transgender recruits and officer candidates.

In fact, senior leaders in the Pentagon were debating whether they should seek a delay. The military’s top brass was still considering various practical questions, including how to fund the retrofitting of showers and the upgrading of shared living spaces; the money for that never materialized.

Late last month, just as the Obama accession policy was to take effect, Mattis approved a six-month delay, saying in a memo to the Defense Department staff that the delay “in no way presupposes an outcome.” Yet from the outset of his tenure, Mattis has said repeatedly that “the Department of Defense must measure each policy decision against one critical standard: will the decision affect the readiness and lethality of the force? Put another way, how will the decision affect the ability of America’s military to defend the nation?”

The president has just given him an answer.

Dan Lamothe contributed to this report.