US Supreme Court Justice Ruth Bader Ginsburg (SAUL LOEB/AFP/Getty)

Liberal US Supreme Court justice Ruth Bader Ginsburg penned a dissent distancing herself from her fellow justices after the court ruled in favour of a bakery that refused to serve a same-sex couple.

The Supreme Court of the United States (SCOTUS) earlier today ruled in favour of Jack Phillips, a baker who was battling the Colorado Civil Rights Commission (CCRC) over his refusal to provide gay wedding cakes.

The court ruled 7-2 in his favour – and though the narrow ruling shied away from setting out a wider case for the right to discriminate based on religion – LGBT groups and allies have expressed fear about the potentially harmful precedent.

Justice Ginsburg penned a scathing dissent conflicting with her fellow justices, joined by fellow liberal Sonia Sotamayor.

Ginsburg wrote: “I strongly disagree with the Court’s conclusion that Craig and Mullins should lose this case.”

Asserting that the actions of the baker were discrimination, she wrote: “Phillips declined to make a cake he found offensive where the offensiveness of the product was determined solely by the identity of the customer requesting it.

“When a couple contacts a bakery for a wedding cake, the product they are seeking is a cake celebrating their wedding — not a cake celebrating heterosexual weddings or same-sex weddings — and that is the service Craig and Mullins were denied.”

She challenged Chief Justice Kennedy’s assertion that the CCRC process discriminated against the baker based on his religious beliefs to the point that the case was found in his favour.

The court’s majority opinion had asserted that CCRC’s Commissioners were “hostile” to Phillips’ religious beliefs due to statements condemning his comments about LGBT people.

But Ginsburg wrote: “Whatever one may think of the statements in historical context, I see no reason why the comments of one or two Commissioners should be taken to overcome Phillips’ refusal to sell a wedding cake to Craig and Mullins.

“The proceedings involved several layers of independent decisionmaking, of which the Commission was but one.”

She concluded: “Sensible application of CADA [Colorado Anti-Discrimination Act] to a refusal to sell any wedding cake to a gay couple should occasion affirmance of the Colorado Court of Appeals’ judgment. I would so rule.”

The narrow ruling in the Masterpiece Cakeshop case avoided setting a wider precedent that would apply to future ‘freedom to discriminate’ cases.

Ginsburg has earned an unlikely following among LGBT liberals in recent years thanks to her unwavering support for equality.

She attracted fury from conservatives by performing several same-sex weddings herself ahead of the court’s 2015 ruling on the issue.

Her frequent dissents from the court’s more conservative justices earned her the nickname ‘Notorious RBG’.

Related: LGBT activists condemn ‘heartbreaking and frustrating’ US Supreme Court decision in bakery case