In mid-April, India’s Supreme Court recognized transgender people as a legal third gender. Grounding its decision on rights guaranteed by the nation’s Constitution as well as international law, the court determined gender identity and sexual orientation to be fundamental to the rights to self-determination, dignity and freedom.

This decision is particularly welcome after another group of justices in December reinstated a colonial-era law that bans gay sex: Section 377 of the Indian Penal Code, which bars “carnal intercourse against the order of nature.” The two contradictory decisions — issued by separate panels of judges — are the result of a quirk of the system. The Supreme Court consists of a chief justice and 30 other justices, with cases often being decided by panels of just two or three judges.

In the transgender case, Section 377 was cited as an instrument of discrimination against transgender people. The court properly recognized the historical and diverse presence of transgender people in Indian society, referring to ancient Hindu and Jain texts and to the place of transgender people in India’s Mughal courts. It listed the different traditional categories of transgender people in India, including hijras, Aravanis, Kothis, Jogtas and Shiv-Shakthis. The court was wise to make this point, since anti-gay-rights groups in India have tried to paint the decriminalization of gay sex and transgender identities as degenerate Western ideas alien to India’s cultural traditions.

The court has directed national and state governments to redress entrenched discrimination suffered by transgender people by recognizing them as an official minority, according them quotas for public jobs and admission to educational institutions, and making sure they are not discriminated against when seeking medical care. Official identity documents are now to include a third gender box.