Three years ago, President Donald Trump reversed the march toward gender and sexuality inclusion in the U.S. military. “After consultation with my Generals and military experts,” he tweeted on July 26, 2017, “please be advised that the United States Government will not accept or allow … Transgender individuals to serve in any capacity in the U.S. Military.” Although the Pentagon had welcomed the contributions of transgender service personnel the year prior, Trump overrode its policy. Despite initial legal challenges, the ban remains in place, and the Trump administration has effectively prevented transgender personnel from serving in the military.

Yet on June 15, the Supreme Court ruled in Bostock v. Clayton County that “an employer who fires an individual merely for being gay or transgender defies the law.” Could this landmark Supreme Court ruling overturn the current military ban on transgender Americans?

Possibly. In fact, 50 years ago as the military began planning for end of the draft, legal decisions helped prod the armed forces toward full inclusion and equal treatment of all its members. That road was rocky, filled with real advances followed by half-measures. But in the end it created a more diverse military with skills and qualifications mattering more than gender and sexual orientation. While the Trump administration created another roadblock, the Court’s ruling in Bostock offers an opportunity for the military to recommit to full inclusion.

For service personnel, equality “on the basis of sex” took far too long to arrive. A key turning point was Frontiero v. Richardson, a landmark Supreme Court sex discrimination case. In 1969, Air Force officer Sharron Frontiero married a civilian man. Typically, dependent spouses of military officers received a housing allowance and medical benefits. Yet after her wedding, Lt. Frontiero’s paycheck and benefits remained the same. Upon inquiring about the missing compensation, Frontiero learned military policy only granted dependent benefits to wives, not husbands. She would not receive the married officer benefits afforded her male colleagues.

Lt. Frontiero sued the military, and when the case reached the Supreme Court, then-ACLU litigator and future Supreme Court Justice Ruth Bader Ginsburg argued for equal treatment. “Sex, like race,” Ginsburg asserted, “has been made the basis for unjustified, or at least unproved, assumptions concerning an individual’s potential to perform or to contribute to society.” In 1973, the court ruled the military could not provide different benefits to its male and female personnel.

The 1973 Frontiero case compelled the military to adopt gender-neutral benefit policies, which helped propel greater inclusion of women in the armed forces. Chief of Naval Personnel Elmo Zumwalt proclaimed women were a “vital personnel resource,” and several key changes followed. These included the elimination of mandatory pregnancy discharges, the dissolution of the segregated Women’s Army Corps, women’s entrance into service academies and the opening of hundreds of new military operational specialties to women.

But what could have been a fast and direct path to making women full and equal members of the military proved plodding and uneven. While the military followed the letter of the law with the Frontiero case, it also resisted the spirit of full inclusion.

The armed forces have more legal latitude to establish policies that might be unlawful in civilian contexts because of the legal doctrine of military deference, the idea that courts ought to “defer” to the military’s policies. According to this argument, civilian judges ought to accept the military’s self-assessment of “effectiveness,” “readiness” and “morale” as justification for policies that might otherwise raise civil rights concerns. As a result, federal judges have tolerated sex discrimination in the military more than in civilian employment.

Relying on this deference, the military resisted women’s equal inclusion. Opponents of women’s full military service — both inside and outside the military — gained traction in the 1980s, arguing too many women might harm military effectiveness. In 1982, the U.S. Army initiated a “woman pause,” restricting women’s enlistment. The military blocked women from a number of military occupational specialties, limited gender integrated training and added new physical requirements for training. It also refused women access to combat units and Special Forces and promoted relatively few women to major leadership positions. It was not until the 21st century that the military promoted any woman to the four-star rank.

Gay and lesbian personnel endured even more discrimination by the military as they increasingly demanded to serve and serve openly. In 1982, under Ronald Reagan’s administration, the Department of Defense argued “homosexuality is incompatible with military service … [it] adversely affects the ability of the Military Services to maintain discipline, good order, and morale.” By the early 1990s, on the heels of the Persian Gulf War and the campaign promises of Bill Clinton, efforts to permit openly gay and lesbian personnel intensified. But the military invoked deference, claiming gay inclusion would lower morale. With the support of conservative lawmakers, military resistance resulted in “Don’t Ask, Don’t Tell” (DADT), an accommodationist policy that allowed only covert homosexuality.

Again and again, as the U.S. military faced political pressure and litigation over a variety of discriminatory sex and gender policies, its leaders argued its own assessments of “harm to morale or readiness” trumped civilian discrimination law. Willing and talented volunteers could not fully or equitably serve their nation’s military.

Over the past 10 years, military leaders have admitted a more inclusive military is stronger. The armed forces have welcomed women and openly gay and lesbian service personnel on equal terms and praised their contributions. In 2010, the U.S. Congress barred the exclusion of gay and lesbian personnel. Five years later in 2015, the military finally opened combat units to women. Secretary of Defense Ashton B. Carter proclaimed gays and lesbians were essential to military readiness and effectiveness, noting they “made our military stronger and our nation safer.” Explaining the decision to drop the combat ban, Carter argued “to succeed in our mission of national defense, we cannot afford to cut ourselves off from half the country’s talents and skills.”

Likewise, in 2016, the Pentagon decided to welcome the approximately 15,500 transgender personnel who were already serving and new transgender recruits. Carter declared, “we can’t allow barriers unrelated to a person’s qualifications prevent us from recruiting and retaining those who can best accomplish the mission.”

The military had repudiated its checkered history of discrimination on the basis of sex and embraced full participation as the best guarantee of military effectiveness. The Trump Administration’s transgender ban undermined the military’s advances. But the Bostock decision prohibiting discrimination against transgender people in civilian employment invites the military to return to its own pre-Trump policy of welcoming all personnel regardless of sex, gender or sexuality. Despite its uneven history, military leadership knows that full and immediate inclusion of transgender personnel would maximize individuals’ military contributions, minimize harmful discrimination and improve military effectiveness.