Forty hours after he was arrested for being gay, Donald Odorizzi, a California schoolteacher, made a decision he would come to regret.

On June 10, 1964, Odorizzi picked up his phone and started dialing numbers at random. These weren’t prank calls. In a time when homosexuality was considered a psychiatric illness, Odorizzi was just a distraught man, fresh off a breakup, looking for someone to talk to.

What happened when the wrong person picked up the phone kicked off a long-forgotten court case that, as the Supreme Court turns rightward five years after the legalization of same-sex marriage, is a window into a dark time for the LGBTQ community.

According to a magazine account at the time, a man answered one of Odorizzi’s calls, and Odorizzi asked him whether he wanted to have sex. The men met in the parking lot of a shopping center, then went to Odorizzi’s apartment. Sitting on his bed, Odorizzi reached out to touch the man.

The man was a member of the Downey, Calif., police department’s vice squad, and Odorizzi was charged with “oral copulation.” He was grilled about his sex life by three police officers for three hours, and the police reported the arrest to the school where he worked.

Though the charges were dropped, the teacher’s ordeal was just beginning. The night after his arrest, his school’s principal and superintendent showed up at his apartment.

“They must feel I’m no good,” Odorizzi later wrote to his attorney.

The administrators drank coffee. They told Odorizzi he was a good teacher. Then, they told him he had to resign to avoid embarrassment. If not, he would be fired.

After 40 hours without sleep, unable to convince the principal and superintendent to wait until the next day for his decision, Odorizzi did something he would fight a two-year legal battle to undo.

“I could no longer stand the duress and emotional strain I was undergoing,” he wrote. “I grabbed a pencil and signed one copy of the resignation.”

Kellye Testy, former dean of the University of Washington School of Law and president of the Law School Admission Council — the organization that administers the LSAT to would-be law students — said she ran across the Odorizzi case while a law student in the 1980s.

The case was in her contracts textbook to explain the doctrine of “undue influence” — the idea that people who sign contracts under pressure aren’t necessarily accountable for them. After he resigned, Odorizzi sued his school district to get his job back.

Three years before the Stonewall riots, in a state unfriendly to gay rights, he succeeded.

“The representatives of the school board undertook to achieve their objection by overpersuasion and imposition,” the California District Court of Appeals wrote in 1966. The administrators got Odorizzi’s signature, the court wrote, “but not his consent … through a high-pressure carrot-and-stick technique.”

Success in a gay rights case half a century ago was no small feat. William Eskridge Jr., a Yale law professor and co-author of “Marriage Equality: From Outlaws to In-Laws,” said gay Californians suffered under an “Earl Warren regime” that lingered for decades.

Warren became a Supreme Court justice in 1953. But as California’s attorney general and governor, he had invented new kinds of “sex crimes” to prosecute, Eskridge said, such as loitering in bathrooms. Laws outlawing consensual sodomy would not be repealed in the state until the mid-1970s.

“California was Earl Warren,” Eskridge said in a phone interview. “It was homophobic and bigoted. Gay people were persecuted.”

The Odorizzi case inspired Testy. She was gay. She had grown up in small-town Indiana with two gay siblings. Here, in a dry legal tome amid cases about construction disputes and maritime law, was an actual gay person. As a law professor in the 1990s — one who developed a pioneering class on law and sexuality — Testy kept returning to Odorizzi v. Bloomfield School District.

“There really weren’t any law materials about gay people,” she said. “It was not something that came up in the classroom very much. … I was really interested in how you bring law and sexuality into classes. The case really interested me.”

Testy tracked down Odorizzi in California around 1997. Though he said the official account of his arrest wasn’t accurate — he hadn’t called numbers at random but had been informed on by an ex-boyfriend — he didn’t want to talk much about it.

“It seems like in the contracts book that Don won,” she said. “But I knew in my heart of hearts no man who went through this won in any sense that mattered.”

Though Odorizzi had prevailed in court, he abandoned teaching, turning to a career in the defense industry. There, he had been targeted by a co-worker — harassed because he was gay — and had to threaten legal action. When Testy asked him about his 1964 arrest, he was reluctant to talk about it.

However, the letters he gave her for a short piece about the case she eventually published in a textbook spoke for themselves.

“I feel that I am FIGHTING FOR MY LIFE,” Odorizzi wrote in a letter to his attorney in 1965. “Shall an agency of the State be empowered to eviscerate me for the rest of my life over the allegation of a crime that was not committed?”

Though his memories are faded, that attorney — Stuart Simke, now 85 — said he took on the Odorizzi case “through a local homosexual organization — the name of which escapes me.”

“I was a young lawyer, and they were going to pay me, and I found it interesting,” he said in a phone interview. “I felt terribly, terribly sorry for him. … He looked and acted like the nicest guy you’d ever want to meet, and I could just see someone who’s flipping out because of depression.”

The Odorizzi case also made its mark on California’s nascent “homophile organizations,” including the magazine Tangents. The magazine, a publication of a social outreach organization for gay men, intervened in the case shortly after Odorizzi’s arrest, bringing in the American Civil Liberties Union for legal assistance.

“The position of educational authorities universally is that homosexuality is concomitant to ‘immoral conduct,’ and, therefore, homosexuals are unfit to teach,” an unsigned editorial in the January 1966 Tangents read. “Mr. Odorizzi does not agree, and for long months he has fought a lonely, unpublicized battle to regain his teaching position and retain his teaching credentials.”

Beyond the court decision itself, this thin historical record is almost all that memorializes Odorizzi. Public records show he died in 2017 at 79.

Joyce Choate, Odorizzi’s first cousin, said he was born in Colorado and became a teacher after attending college. Offered a choice to teach in Detroit or California, Odorizzi chose California and rarely came back.

“He said, ‘I had to get the hell out of there,’ ” said Choate, who lives in Denver. “He didn’t want to stay around. He knew he had to get out, and I don’t blame him, and he ended up having a good life in California. So it was good.”

Choate said she and Odorizzi were “best friends” even though Odorizzi was more than a decade older. They talked on the phone daily between 2007 — when Odorizzi, a heavy smoker, was diagnosed with cancer — and his death.

She said her cousin was a great cook and had traveled to 56 countries. He also had a partner who lived with him. As Odorizzi’s health declined, he became nostalgic, Choate said.

“He told me he missed the good old days when he was good-looking — and he was good-looking,” she said.

Choate said he did not speak about his court case or the adversity he faced.

Same-sex marriage was legalized by the U.S. Supreme Court in the 2015 case Obergefell v. Hodges. Justices Clarence Thomas and Samuel A. Alito Jr. criticized the decision from the bench in an October opinion, saying “the Court has created a problem that only it can fix.” New Justice Amy Coney Barrett, the keystone of a stronger conservative majority, has also said she is skeptical of the decision.

Eskridge said he thought it unlikely that the court will “turn back the clock to where gay people are psychopaths and criminals.” The court protected the rights of transgender workers in June, even as Alito wrote what Eskridge said was a “hard-hitting dissent.” It is now considering whether private foster-care agencies can reject same-sex foster parents.

“Look at how far we’ve come since 1964 and Odorizzi,” he said. “The courts have played a modestly positive role in that by giving decent people protection against very unjust treatment.”

Testy was more skeptical. Gay people feel vulnerable right now, she said.

“The progress the gay rights movement made in the 1990s did not just happen,” she said, noting the work of people who fought for change. “It will be harder to undo because so much of culture has changed, but I still think the institutions can do damage.”