The Supreme Court on Monday narrowly sided with a Colorado baker who refused to bake a wedding for a gay couple.

In a 7-2 decision, the justices said that the Colorado Civil Rights Commission showed hostility toward baker Jack Phillips' religious beliefs when it found that he had violated the state's anti-discrimination law.

The commission found that Phillips, the owner of Masterpiece Cakeshop, had violated Colorado law when he refused to bake a cake for Dave Mullins and Charlie Craig's 2012 Denver wedding reception. (At the time, Colorado did not issue marriage licenses to gay and lesbian couples. The men married in Massachusetts.)

The couple sued, saying that Phillips' faith does not give him a right to discriminate, and a Colorado court found that Phillips had discriminated against the men under Colorado law. After the Colorado Supreme Court declined to hear an appeal, Phillips turned to the Supreme Court, arguing that the First Amendment protects his religious rights.

The high court concluded that Phillips' religious rights under the First Amendment had been violated by the commission. But the narrow ruling seems to only apply to Phillips.

Justice Anthony Kennedy, who also wrote Obergefell, the landmark 2015 ruling that struck down state laws and constitutional amendments that excluded gay couples from marriage, wrote Monday's decision.

The state commission's hostility toward religion “was inconsistent with the First Amendment's guarantee that our laws be applied in a manner that is neutral toward religion,” Kennedy wrote.

President Donald Trump's Department of Justice had filed a brief in support of Phillips. Attorney General Jeff Sessions cheered the ruling. “The First Amendment prohibits governments from discriminating against citizens on the basis of religious beliefs,” he said in a statement.

The Human Rights Campaign (HRC), the nation's largest LGBT rights advocate, said that the ruling's narrow scope reaffirms “that LGBTQ Americans should not face discrimination in the provision of goods and services and state laws may continue to prohibit such discrimination.”

“In today’s narrow ruling against the Colorado Civil Rights Commission, the Supreme Court acknowledged that LGBTQ people are equal and have a right to live free from the indignity of discrimination,” HRC President Chad Griffin said in a statement. “Anti-LGBTQ extremists did not win the sweeping ‘license to discriminate’ they have been hoping for – and today’s ruling does not change our nation's longstanding civil rights laws. Yet, the fact remains that LGBTQ people face alarming levels of discrimination all across the country and HRC’s efforts to advance equality are as urgent as ever. With LGBTQ people at risk of being fired, evicted or denied services in 31 states, HRC continues to build momentum for the Equality Act, to elect pro-equality candidates up and down the ballot, and to fight in every corner of our country to advance policies that protect LGBTQ people from being targeted for who they are or whom they love.”