The Supreme Court agreed on Monday to hear an appeal from a Colorado baker with religious objections to same-sex marriage who had lost a discrimination case for refusing to create a cake to celebrate such a union.

The case will be a major test of a clash between laws that ban businesses open to the public from discriminating based on sexual orientation and claims of religious freedom. Around the nation, businesses like bakeries, florists and photography studios have said, so far with little success, that forcing them to serve gay couples violates their constitutional rights.

The Supreme Court’s decision, expected next year, will again take the justices into a heated battle in the culture wars. On one side are gay and lesbian couples who say they are entitled to equal treatment from businesses that choose to serve the general public. On the other are religious people and companies who say the government should not force them to choose between the requirements of their faiths and their livelihoods.

In a series of decisions culminating in its 2015 ruling establishing a constitutional right to same-sex marriage, the Supreme Court has consistently ruled in favor of gay rights. But it has also said that businesses run on religious principles may sometimes be exempted from generally applicable laws, as when it ruled in 2014 that some companies could not be required to provide free contraceptive coverage for their female workers.

The new case, Masterpiece Cakeshop v. Colorado Civil Rights Commission, No. 16-111, started in 2012, when the baker, Jack Phillips, an owner of Masterpiece Cakeshop in Lakewood, Colo., refused to create a cake for the wedding reception of David Mullins and Charlie Craig, who were planning to marry in Massachusetts. The couple filed discrimination charges, and they won before a civil rights commission and in the courts.

“This has always been about more than a cake,” Mr. Mullins said. “Businesses should not be allowed to violate the law and discriminate against us because of who we are and who we love.”

Mr. Phillips, who calls himself a cake artist, argued that two parts of the First Amendment — its protections for free expression and religious freedom — overrode a Colorado anti-discrimination law and allowed him to refuse to create a custom wedding cake.

David Cortman, one of Mr. Phillips’s lawyers, said the case concerned fundamental rights. “Every American should be free to choose which art they will create and which art they won’t create without fear of being unjustly punished by the government,” he said.

In 2015, a Colorado appeals court ruled against Mr. Phillips. “Masterpiece does not convey a message supporting same-sex marriages merely by abiding by the law and serving its customers equally,” the court said.

In a Supreme Court brief, Mr. Phillips’s lawyers said “he is happy to create other items for gay and lesbian clients.” But his faith requires him, they said, “to use his artistic talents to promote only messages that align with his religious beliefs.”

“Thus,” the brief said, “he declines lucrative business by not creating goods that contain alcohol or cakes celebrating Halloween and other messages his faith prohibits, such as racism, atheism, and any marriage not between one man and one woman.”

The brief said Mr. Mullins and Mr. Craig could have bought a cake from another baker and in fact “easily obtained a free wedding cake with a rainbow design from another bakery.”

Full story at The New York Times.