A federal judge in New York ruled on Tuesday that the Off Broadway play “3C,” a darkly comic reimagining of the TV hit “Three’s Company,” did not infringe the copyright of that decades-old sitcom. In the ruling, Judge Loretta A. Preska of the United States District Court wrote that the play represented a “drastic departure” from the TV show, which ran from 1977 to 1984 and remains in syndication.

“3C,” written by David Adjmi, had a two-month run at Rattlestick Playwrights Theater in 2012, when it opened to mixed reviews. Mr. Adjmi said that on opening night he received a cease-and-desist letter from DLT Entertainment, the copyright holder of “Three’s Company.” While the Rattlestick run continued, the play was held in a kind of purgatory: Mr. Adjmi said he couldn’t license it for other productions or publish the script in a collection of his works because of the threat of litigation.

After negotiations failed, Mr. Adjmi chose to take DLT to court, with pro bono representation, last year. “My lawyers said the only way to get any forward movement was to sue them,” he said in an interview from Rome, where he is on a fellowship. “I thought, oh gosh, that seems really extreme, and I was a little scared. But I didn’t want this to stay in limbo forever.”

“Three’s Company” starred Suzanne Somers and Joyce DeWitt as roommates, and John Ritter, who pretended to be gay to move in with them. “3C” followed similar outlines — a trio of roommates, nosy neighbors and ’70s haircuts were a staple onstage, too — but farcical elements were leavened with profanity and sexual situations that would never have played on broadcast TV.