In more than three decades on the Supreme Court, Justice Anthony M. Kennedy wrote the majority opinion in every landmark case that advanced gay rights — most notably Obergefell v. Hodges, which legalized same-sex marriage across the U.S. in June 2015. Almost three years to the day after that ruling, Kennedy on Wednesday announced he will retire at the end of next month.

Kennedy’s announcement led to both discussions about his legacy as an LGBTQ rights proponent as well as fear about what his departure from the bench will mean for LGBTQ rights moving forward.

LGBTQ-RIGHTS LEGACY

In 1996, Kennedy wrote the majority opinion in Romer v. Evans, a 6-3 decision that struck down Amendment 2 of the Colorado Constitution, which barred local governments from recognizing gay men and lesbians as a protected class.

“We must conclude that Amendment 2 classifies homosexuals not to further a proper legislative end but to make them unequal to everyone else. This Colorado cannot do,” Kennedy wrote for the majority. “A state cannot so deem a class of persons a stranger to its laws. Amendment 2 violates the Equal Protection Clause.”

Then in 2003, Kennedy wrote for the majority in Lawrence v. Texas, a 6-3 decision that struck down Texas’ anti-sodomy law, and thus all the remaining anti-sodomy laws across the country. In essence, the ruling legalized consensual homosexual activity across the U.S.

“The petitioners are entitled to respect for their private lives. The state cannot demean their existence or control their destiny by making their private sexual conduct a crime,” Kennedy wrote in his court opinion. “The Texas statute furthers no legitimate state interest which can justify its intrusion into the personal and private life of the individual.”

A decade later, Kennedy cast the deciding vote in the 2013 decision United States v. Windsor, which struck down a crucial part of the Defense of Marriage Act, or DOMA, a 1996 law that barred the federal government from recognizing same-sex unions.

“The principal purpose and the necessary effect of this law are to demean those persons who are in a lawful same-sex marriage,” Kennedy wrote for the majority. “This requires the court to hold, as it now does, that DOMA is unconstitutional as a deprivation of the liberty of the person protected by the Fifth Amendment of the Constitution.”

Just two years later, Kennedy cast the deciding vote in Obergefell v. Hodges.

“No union is more profound than marriage, for it embodies the highest ideals of love, fidelity, devotion, sacrifice, and family,” Kennedy wrote for the majority. "In forming a marital union, two people become something greater than once they were."

Supreme Court Associate Justices Anthony Kennedy, right, and Stephen Breyer testify on Capitol Hill in Washington on March 23, 2015. Manuel Balce Ceneta / AP file

He concluded: “As some of the petitioners in these cases demonstrate, marriage embodies a love that may endure even past death. It would misunderstand these men and women to say they disrespect the idea of marriage. Their plea is that they do respect it, respect it so deeply that they seek to find its fulfillment for themselves. Their hope is not to be condemned to live in loneliness, excluded from one of civilization’s oldest institutions. They ask for equal dignity in the eyes of the law. The Constitution grants them that right."

"WAY OUT FRONT" ON GAY RIGHTS

A former law clerk of Kennedy's, Michael C. Dorf, now a constitutional law professor at Cornell University, said his former boss “didn’t just write” the court’s decisions on LGBTQ rights, he was “way out in front.”

“In each of these cases, he emphasized the dignitary harm that discrimination against LGBT people does,” Dorf told NBC News. “I think he got there well before the country, but he sort of waited and moved along and took the country with him in a lot of ways.”

Janson Wu, executive direct of GLBTQ Legal Advocates & Defenders (GLAD), said, “Kennedy’s legacy on LGBTQ rights has been monumental.”

“Thanks to his decisions from Romer to Obergefell, LGBTQ individuals not only do not have to worry about being criminalized for who they love, but now can marry the person that they love,” Wu said. “Justice Kennedy made clear over the multiple decisions that he wrote that LGBTQ people are equal citizens in the eyes of the law.”

Even in this month’s narrow ruling in the Masterpiece Cakeshop case, where Kennedy sided with a Colorado baker who refused to make cake for a gay wedding, Wu said Kennedy reasserted his belief that there’s no constitutional right to discriminate based on religious beliefs.

"These disputes must be resolved with tolerance, without undue disrespect to sincere religious beliefs, and without subjecting gay persons to indignities when they seek goods and services in an open market," Kennedy wrote for the majority in the Masterpiece decision.

FEARS OF A COURT WITHOUT KENNEDY

A number of LGBTQ advocacy groups expressed concern that a Supreme Court without Kennedy could mean a rollback of LGBTQ rights.

"Justice Anthony Kennedy's retirement will allow President Trump to fill his vacancy with yet another anti-LGBTQ justice with a lifetime appointment," Sarah Kate Ellis, president of LGBTQ media advocacy group GLAAD, said in a statement.

Rachel Tiven, the CEO of Lambda Legal, an LGBTQ rights organization, said, "We are shocked and saddened that a justice who was once the defender of dignity for LGBT people and our families on the court would chose this moment to hang up his robe and give the Trump administration the opportunity to further derail anti-discrimination laws and undermine the rule of law.”

Tiven also advocated for a block on any nominee Trump puts forward until after the November midterm elections.

“Given everything happening in this country, and the fact that this president has worked to push through his own hateful agenda, the American people have a right to be heard before this critical decision,” Tiven said in a statement.

While Dorf said Kennedy’s departure is unlikely to precipitate a rollback of LGBTQ rights, he did speculate that if Kennedy were to remain on the bench, he probably would have further advanced LGBTQ rights.

“There are many state and local statutes and ordinances that forbid LGBT discrimination, but there’s nothing at the federal level,” Dorf explained. “We might have expected Justice Kennedy to eventually write an opinion that says LGBTQ discrimination is unconstitutional."

After nearly 31 years of service on the Supreme Court, Kennedy's last day will be July 31.

FOLLOW NBC OUT ON TWITTER, FACEBOOK AND INSTAGRAM