When the Supreme Court of India ruled on Wednesday that it would reverse the decision of a lower court and uphold the constitutionality of a law that effectively criminalizes homosexuality, there was widespread shock. Most observers had assumed that the justices would endorse an earlier ruling of the Delhi High Court that had determined, in 2009, that Section 377 of the Indian Penal Code—which proscribes “unnatural offenses”—did not apply to sexual relations between consenting adults. But a look back at the arguments presented in the case, which took place last year, makes it clear that upholding the law was, in fact, the likely verdict.

The text of Section 377—a gift from our departed British friends dating back to 1860—states that “Whoever voluntarily has carnal intercourse against the order of nature with any man, woman or animal” shall be subject to a punishment up to life imprisonment. The law does not specify what might constitute “carnal intercourse against the order of nature,” other than to note that “penetration is sufficient to constitute the carnal intercourse” cited. But, as the Delhi High Court wrote in its earlier judgment, the courts had interpreted the law to include “oral sex, anal sex, and penetration of other orifices” in the past; in other words, it criminalized all sexual acts apart from heterosexual vaginal intercourse. Convictions have been rare, but the law has been enforced almost exclusively against homosexuals, and the police have frequently employed it as a tool of harassment and blackmail.

In its decision, the Delhi High Court had “read down” the law, meaning that it would only apply to minors and non-consensual sex. Criminalizing sexual acts between consenting adults, the court found, would violate the Indian Constitution’s guarantees of dignity, equality, and freedom from discrimination. That case had begun in 2001, when the Naz Foundation, a nonprofit AIDS-prevention organization, filed a petition arguing, among other things, that its outreach to at-risk men was hampered by the criminalization of gay sex. Two parties came forth to oppose the petition: a retired police officer and right-wing Hindu ideologue named B. P. Singhal, who served as a member of parliament for the Bharatiya Janata Party, and a nonprofit group called Joint Action Committee, Kannur, which calls itself JACK India.

The impact of the Delhi High Court ruling in 2009 was considerable. Pride parades bloomed across India, even in small cities; the news media and Bollywood alike suddenly woke up to the existence of homosexuality. Perhaps as a result of this new opening, when an astrologer named Suresh Koushal filed an appeal against the judgment in the Supreme Court, fifteen other parties joined him and the original litigants to support upholding Section 377. These included the secretary to a popular yoga guru; an organization called the Krantikari Manuwadi Morcha, whose name suggests its mission to preserve upper-caste power; the Delhi Commission for the Protection of Child Rights; and three Muslim and three Christian organizations.

The case was argued over several hearings, in February and March of 2012, before two Supreme Court justices, G. S. Singhvi and S. J. Mukhopadhyay. Notes on the proceedings, which have been published online by the Bangalore-based Alternative Law Forum, suggest that the judges were both bemused and puzzled by the case before them, and had little inclination to challenge some of the more dubious arguments advanced in favor of Section 377. “We never used to discuss this,” Mukhopadhyay said at one point, referring to sex. “Now we are openly discussing it in court.”

There was, indeed, much discussion of sex. The judges wanted to know what the word “carnal” in the law meant, what the law intended to proscribe as “against the order of nature,” and what sexual acts might be banned under Section 377 if “penetration” was the key criteria.

Amarendra Sharan, the lawyer for the Delhi Commission for the Protection of Child Rights, argued that only sex between a man and a woman was “natural,” because it has the possibility of procreation. “Any penetration of the sexual organ” that does not, he continued, “will be against the order of nature.” Sharan was asked by the judges about the meaning of “carnal” and “penetration,” and read from a 1969 case that defined “carnal intercourse” as “the temporary visitation of an organization” by the penis, “where the primary object was to obtain euphoria, and where the visiting member was partially enveloped by the organization.” On that basis, Sharan argued, even mutual masturbation should be considered both “unnatural” and penetrative, and disallowed under Section 377.

Sharan read the definitions of “penetration,” “intercourse,” and “carnal” from a dictionary. He was asked what was meant by “against the order of nature”: “If a gynecologist inserts a hand inside, to find out if a baby is all right,” Justice Mukhopadhyay asked, “is it against the ‘order of nature’?” No, Sharan replied, because there would be “no element of carnal, no sexual satisfaction.” He was then asked if the insertion of the penis into the nose would constitute carnal intercourse—a reference to an earlier case, dating from the nineteen-twenties, in which a man was convicted of an “unnatural offense” for having intercourse with the nose of a cow.

It was left to the eminent lawyer Fali Nariman, who was representing a group of parents of gay, lesbian, bisexual, and transgender persons, to clear up the confusion over the language of the law. Nariman explained to the court that the culprit was Thomas Babington Macaulay, the British politician and historian who was the primary author of the 1860 Indian Penal Code. Nariman quoted Macaulay, who had explained the deliberate ambiguity of the wording by insisting that he was “unwilling to insert, either in the text or in the notes, anything which could give rise to public discussion on this revolting subject.” Any benefits that might arise from a more precise wording, Macaulay said, would be far outweighed by “the injury which would be done to the morals of the community by such discussion.”

The defendants argued that such Victorian squeamishness was obviously outdated, and pointed to the consequences of Section 377 for the prevention and treatment of AIDS. Both sides cited the fact that gay men are a “high-risk group” for H.I.V. in India. The defendants argued that decriminalization was necessary to insure that gay men could obtain care and treatment without fear of prosecution. The petitioners, however, insisted that since gay men were a “high-risk group,” the government should not “encourage” homosexuality by decriminalizing it. The lawyer representing one of the Christian groups, Trust God Ministries, criticized the Naz Foundation for its work on behalf of gay men, arguing that it should have been working instead to cure their homosexuality.

An even more radical argument came from Purushottaman Mulloli, of JACK India, who insisted that government figures on the number of AIDS patients had been falsified in order to justify additional funding. When I interviewed Mulloli at the time of the original decision, in 2009, he told me that his organization is of the opinion that AIDS is a myth. “This act had to go,” he argued in court of Section 377, “because there is a multi-billion-dollar business behind it.” He wants homosexuality to remain criminalized because he believes that decriminalization provides an excuse for global pharmaceutical companies to sell expensive drugs to treat a nonexistent disease. “I am standing as a symbol of the Constitution,” Mulloli told the court, against “the might of an N.G.O. on the other side—Bill Clinton, Bill Gates, they have their support. Their massive organization and strength, I can’t withstand.”