For indispensable reporting on the coronavirus crisis, the election, and more, subscribe to the Mother Jones Daily newsletter.

In its decision this week in Masterpiece Cakeshop v. Colorado Civil Rights Commission, the Supreme Court wanted a way to rule narrowly in favor of a Colorado baker who refused to sell a wedding cake to a same-sex couple, without upsetting decades of civil rights law. It seems to have found the answer to its conundrum in a stunt pulled by a religious-right activist. The effectiveness of the stunt, and its embrace by the court’s conservative justices, illustrates the extent to which Christian legal organizations are influencing the law, all the way to the Supreme Court.

In 2014, a man named William Jack paid a visit to Azucar Bakery in Denver. There, Jack demanded two cakes, both in the shape of an open Bible. On one, he wanted “Homosexuality is a detestable sin – Leviticus 18:22” written on one side of the Bible and “God hates sin Psalm 45:7” on the other. On the second cake, he asked the bakery to inscribe “God loves sinners” and “While we were yet sinners Christ died for us. Romans 5:8” and to include an iced illustration of two men holding hands in front of a cross, covered with what Jack described as a “Ghostbusters symbol,” a red circle with a line through it to indicate that such unions are “un-Biblical.”

The bakery’s owner, Marjorie Silva, told Jack she’d sell him the Bible cakes but wouldn’t write the words on them. She offered to sell him a decorating bag, tip, and icing so he could put the message on himself. Jack returned two more times that day, at one point asking if she’d conferred with a lawyer, but she continued to refuse to sell him the cakes he wanted. When he left for the last time, he told her, “You will hear from me!” Silva told Out Front magazine.

Jack visited two other Denver bakeries that he’d identified from LGBT websites as gay-friendly and made similar requests. He refused to tell the bakers why, exactly, he wanted the cakes or what he was planning to celebrate with them. The other bakeries, which like Azucar regularly made religious cakes, also declined to fill Jack’s order on the grounds that his messages were offensive and hateful. Shortly after the visits, Jack filed a complaint against the three bakeries with the Colorado Civil Rights Division—which ruled in favor of the same-sex couple in the Masterpiece Cakeshop case—alleging that they had discriminated against him because he is a Christian.

Jack isn’t just a guy who wanted a cake. He’s a foot soldier in the religious-right evangelical movement. He co-founded the Worldview Academy, a Christian organization that runs summer camps that teach kids how to live in “accord with a Biblical worldview.” Jack also ran a creationist youth ministry and made a name for himself as the founder of BC Tours, an organization that gives home-schooled children and their parents “Biblically Correct” tours in Denver to places like the Denver Museum of Nature and Science and the Denver Zoo. The tours tell participants how, contrary to the museum exhibits, Adam and Eve walked the earth with dinosaurs, the earth is only 6,000 years old, and fossils were mostly created by Noah’s flood.

In August, Jack co-hosted an episode of the radio show of the radical right-wing minister Kevin Swanson, who believes that homosexuality should be punished by death. In the show, Swanson declared that public schools in Washington State that teach kids about transgender identity “are whorehouses.” Jack replied, “We need to burn ’em down.”

Jack did not respond to a call seeking comment, but he has published a series of videos to YouTube detailing his “undercover” operation against the bakeries, titled “Would Jesus Bake This Cake?”

Jack told the Blaze that he had filed the complaints against the bakers to show that the state was applying its anti-discrimination statute unequally, punishing religious people like the baker who refused to make the same-sex-marriage cake in the Masterpiece Cakeshop case but not Silva and the others who wouldn’t make Jack’s requested cakes. In March 2015, the Colorado Civil Rights Division, the investigative arm of the Civil Rights Commission, officially rejected his complaints. Three weeks later, lawyers from Alliance Defending Freedom, an anti-gay-marriage nonprofit representing Masterpiece Cakeshop, filed a notice with the Colorado Court of Appeals flagging the decisions in Jack’s cases to bolster their own, which was then pending in the court.

As the same-sex-marriage wars were heating up before the Supreme Court’s 2015 decision legalizing such marriages, the country was awash in bakery stunts. Azucar was targeted again in 2015 by another activist, Robert Mannarino, who called and attempted to order a cake that read, “The Bible says gay marriage is wrong.” The bakery refused to make the cake, and Mannarino filed a complaint with the Colorado Civil Rights Division. (Silva has since sold the bakery and couldn’t be reached for comment, and the Civil Rights Division wouldn’t disclose the outcome of that complaint.)

That same year, Arizona evangelist Joshua Feuerstein posted a YouTube video of himself calling Cut the Cake, an Orlando bakery, and trying to order a cake that said, “We do not support gay marriage.” In the video, Feuerstein rails against the bakery owner, Sharon Haller, for being intolerant of religious people after she turned down his order. The video prompted Feuerstein’s followers to make hundreds of threatening phone calls to the bakery.

That’s why, when Mannarino called Cut the Cake and tried to order a cake inscribed with “Homosexuality is an abomination unto the Lord,” Haller assumed it was another prank. She told him she’d do it—for $150 a letter, or about $6,000. The next time she heard from him, he had filed a complaint against the bakery with the Florida Commission on Human Relations. A Florida administrative law judge ruled against Mannarino in 2017.

Stunts like these aren’t uncommon among activist groups of all political leanings seeking changes in the legal system. Civil rights organizations use testers, for instance, to see whether a landlord is refusing to rent to people of color or a car dealer is charging them higher interest on auto loans. Activists who use wheelchairs visit businesses to see whether their buildings comply with the Americans With Disabilities Act, and file complaints if they don’t. But these testers are usually representative of larger numbers of people who’ve genuinely been discriminated against. There doesn’t appear to be a huge group of customers looking for gay-bashing cakes who can’t procure them.

Nonetheless, Jack’s work turned out to be wildly successful. Even though no judge has ruled in his favor, the Supreme Court used his stunts to craft its ruling in Masterpiece Cakeshop.

The court’s conservative justices clearly wanted to rule in favor of the baker, Jack Phillips. But doing so risked opening the door to religious justifications for all sorts of discrimination. It would be hard, if not impossible, to persuade any of the court’s liberal justices or swing justice Anthony Kennedy—the author of the court’s 2015 decision to legalize same-sex marriage—to sign on to a broad ruling in Phillips’ favor.

The court found a novel way out in William Jack.

Seizing on Jack’s story, it managed to avoid ruling on Phillips’ behavior and instead focus on the Colorado Civil Rights Commission. The commission, the court’s majority found, had treated Phillips unfairly simply because he objected to same-sex marriage on religious grounds. By doing so, the court said, the commission had violated his rights under the Free Exercise Clause of the Constitution.

As evidence, the justices pointed to the way the commission had treated Jack in his three cases against the other Colorado bakers. Jack’s story was laid out in detail in an amicus brief he filed in the Masterpiece case, with help from the National Center for Law and Policy, a Christian nonprofit law firm affiliated with Alliance Defending Freedom, the group representing Phillips. In the brief, Jack argued, “A baker in Colorado is free to refuse to bake a custom cake if the requested cake design is—in the eyes of the baker—offensive or objectionable, but only if the unpopular message is a religious view critical of same-sex marriage.”

Kennedy largely agreed, writing for the majority, “The treatment of the conscience-based objections at issue in these three cases contrasts with the Commission’s treatment of Phillips’ objection.” He suggested that the differing treatment was proof that the commission was hostile to Phillips’ religious beliefs. Justice Neil Gorsuch elaborated for many pages on this idea, drawing heavily from Jack’s brief. “Maybe most notably, the Commission allowed three other bakers to refuse a customer’s request that would have required them to violate their secular commitments,” he wrote in a concurring opinion. “Yet it denied the same accommodation to Mr. Phillips when he refused a customer’s request that would have required him to violate his religious beliefs.”

That didn’t sit well with Justice Elena Kagan, one of two liberals who joined in Kennedy’s majority opinion. Phillips refused even to discuss a cake with the gay couple, Kagan observed, instead denying them a cake simply because they were gay. “The three bakers in the Jack cases did not violate that law,” Kagan wrote in a concurrence, referring to the Colorado Anti-Discrimination Act. “[T]he bakers did not single out Jack because of his religion, but instead treated him in the same way they would have treated anyone else.”

“He was treated as any other customer would have been treated—no better, no worse,” Justice Ruth Bader Ginsberg wrote in a dissent. In a footnote, she took direct aim at Gorsuch for equating Jack with Charlie Craig and David Mullins, the couple that tried to buy the wedding cake at the Masterpiece Cakeshop. “Change Craig and Mullins’ sexual orientation (or sex), and Phillips would have provided the cake,” she wrote. “Change Jack’s religion, and the bakers would have been no more willing to comply with his request. The bakers’ objections to Jack’s cake had nothing to do with ‘religious opposition to same-sex weddings.’”

Despite the criticism from Kagan and Ginsburg, Jack’s cases will have a long shelf life. Because the Masterpiece Cakeshop ruling was so narrow, it didn’t put an end to the legal battles over when the religious freedom rights of a business owner can trump the civil rights of LGBT people. Alliance Defending Freedom and other Christian legal outfits are representing a host of other plaintiffs, from florists to videographers, who are suing for the right not to serve LGBT people. Jack’s work has found its way into one of those, too.

This story has been updated to include Jack’s appearance on Kevin Swanson’s radio show.