Maryland’s highest court has ruled that non-biological parents who live with and help raise children also have parental rights, overturning a 2008 decision that gay and lesbian advocates considered devastating to same-sex couples.

In a unanimous ruling issued Thursday, the Maryland Court of Appeals ruled that family-court judges can consider whether a person is a “de facto” parent in custody and visitation cases. Advocates say Maryland was one of few states that considered such parents strangers in the eyes of the law.

De facto parents can include the partner of a lesbian who undergoes artificial insemination, a gay man whose partner adopts a child from a country that does not allow same-sex couples to jointly adopt, or a straight man who raises a child with a woman for years without formal adoption.

Until the 2008 court decision, such people generally had the ability to maintain some parental rights in Maryland even when their relationships with their partners crumbled.

Then the Court of Appeals ruled against a Baltimore County woman who sought custody or visitation rights with a girl who had been adopted by her ex-partner. The court said “third party” parents should not be treated differently from other third parties seeking custody. That meant they would need to show exceptional circumstances or that the legal parent was unfit in order to be awarded time with children they had helped raise.

This week’s ruling concerned a different case and reversed the precedent set by the court in 2008. Denying rights to third-party parents “is ‘clearly wrong’ and has been undermined by the passage of time,” Judge Sally D. Adkins wrote in the decision.

LGBT advocates hailed the ruling for correcting what they saw as a continuing injustice against the lesbian, gay, bisexual and transgender community, even after voters legalized same-sex marriage in 2012.

“Now Maryland joins the majority of other states in taking those parents and children out of limbo and putting them in solid legal footing,” said Jer Welter, a lawyer with FreeState Justice who represented plaintiff Michael Conover in the case ruled on this week.

Conover is a transgender man who had married a woman before undergoing his gender transition. Their wedding took place in the District, which legalized same-sex marriage before Maryland did. Courts treated him and his ex-wife as a same-sex couple for the purpose of the dispute.

Brittany Conover gave birth in 2010 to a child, Jaxon, who was fathered by a sperm donor selected with the input of Michael Conover, then known as Michelle, according to court records. The couple separated the next year and divorced in 2013.

Brittany Conover stopped allowing her spouse to visit in 2012. She argued in a later custody battle that her former partner never adopted Jaxon and was not listed as a parent on the child’s birth certificate.

Lower courts agreed that Michael Conover lacked parental rights. The Court of Appeals ruling returns the case to a Washington County judge with the concept of a de facto parent restored in law.

“I am elated that the state’s highest court has ruled that people like me should have our relationships with our children legally protected,” Michael Conover said in a statement.

R. Martin Palmer Jr., an attorney for Brittany Conover, said the court usurped the role of lawmakers in defining a parent and may have created a situation in which stepfathers can take control of children from capable mothers.

“Seeking to serve the needs of the LGBT community has created a bad situation for traditional families and their children,” Palmer said.

Nancy Polikoff, a family-law professor at American University who studies LGBT issues, said the ruling does not address all issues nontraditional parents face, including what happens when parent split up before an artificially conceived child is born and whether the children of non-biological parents qualify for benefits after their death.

Legal agreements and formal adoption can stave off some of these disputes.

Cathy Sakimura, family-law director for the National Center for Lesbian Rights, said advocates are waiting for court decisions in New York and Vermont that could also recognize de facto parents, a concept already recognized in more-conservative states such as Texas and North Carolina. “We have really advanced with marriage equality, but we don’t have family equality,” Sakimura said.

Maryland state lawmakers unsuccessfully tried to pass a bill recognizing rights of non-adoptive parents in the wake of the 2008 ruling and were waiting for the resolution of the Conover case to try again.

Margaret Kahlor, who unsuccessfully sought custody in the 2008 case, said she cried when she opened up an email telling her the court had overturned the case that ended in her losing contact with her daughter Maya. The girl will turn 18 in several months, and at that point Kahlor hopes to see her for the first time in eight years.

“What’s important is what happens to the families behind me,” said Kahlor, a 53-year-old community-college employee. “Their children cannot be taken away.”