Early on, lesbian, gay, bisexual and transgender people seemed to be exempted from Donald Trump’s most inflammatory rhetoric. He was the first Republican presidential nominee to mention LGBT people in his acceptance speech. After his election, he declared same-sex marriage "settled law." Once in office, he left in place an executive order protecting the federal government’s LGBT employees from discrimination.

But any early optimism among gay-rights supporters has disintegrated in recent months. The Trump administration has rescinded policies that supported transgender students and soldiers and signaled its opposition to gay rights in a pair of federal cases.

Most recently, the U.S. Justice Department filed a brief in support of Masterpiece Cakeshop, a Colorado bakery that refused on religious grounds to make a cake for a gay couple’s wedding. The bakery was sanctioned by the state, and the U.S. Supreme Court is scheduled to hear the case this fall. The Department of Justice supported the argument that cake decoration is artistic expression and therefore deserves special protection.

It’s the latest of a series of rebukes to the last half-dozen years, a period of wide expansion and affirmation of gay rights. President Barack Obama ended the administration’s support of the 1996 Defense of Marriage Act in 2011; two years later, the Supreme Court struck down part of that law. In 2015, the court declared same-sex marriage legal nationwide.

Obama also used executive orders and agency directives to shore up LGBT protections, and 21 states, including Colorado where the Masterpiece Cakeshop is located, have forbidden businesses from denying accommodation or services to people based on sexual orientation.

At the same time, public opinion on same-sex marriage has shifted dramatically to favor allowing gay and lesbian couples to wed. As recently as 2011, the public was about evenly split on the issue, according to the Pew Research Center. As of June, those in support outnumbered those opposed by two-to-one. For the first time, even Republicans were evenly split.

Two of the Trump administration’s actions reversed specific protections for transgender people. First, the Department of Education undid an Obama-era policy that supported transgender students’ access to bathrooms in public schools.

This summer, Trump tweeted that he had decided to ban transgender people from serving in the military and followed a month later with an official directive to the Pentagon.

Lambda Legal, an LGBT legal advocacy group, filed a lawsuit late last month challenging the transgender military ban, as did other supporters of transgender military service. Defense Secretary Jim Mattis has said that transgender troops will be allowed to continue military service pending a study by a panel of experts.

The latest shift is probably just the beginning, said Sarah Warbelow, legal director for the Human Rights Campaign, the largest LGBT advocacy group. The Justice Department will have opportunities to de-emphasize enforcement of protections for LGBT people in other areas -- and to weigh in when LGBT advocates look to the courts to defend their rights.

"We feel confident that the law stands by us, that the court is going to rule on the side of equal rights and the core principals of decency that have governed the U.S. for so long," said Louise Melling, deputy legal director of the American Civil Liberties Union, which is representing the gay couple in the Masterpiece Cakeshop case.