India's Supreme Court has recognised transgender people as a third gender, in a landmark ruling.
"I00t220 0is the right of every human being to choose their gender," it said in granting rights to those who identify themselves as neither male nor female.
It ordered the government to provide transgender people with quotas in jobs and education in line with other minorities, as well as key amenities.
According to one estimate, India has about two million transgender people.
In India, a common term used to describe transgender people, transsexuals, cross-dressers, eunuchs and transvestites is hijra.
Campaigners say they live on the fringes of society, often in poverty, ostracised because of their gender identity. Most make a living by singing and dancing or by begging and prostitution.
Members of the third gender have played a prominent role in Indian culture and were once treated with great respect. They find mention in the ancient Hindu scriptures and were written about in the greatest epics Ramayana and Mahabharata.
In medieval India too, they played a prominent role in the royal courts of the Mughal emperors and some Hindu rulers. Many of them rose to powerful positions.
Their fall from grace started in the 18th Century during the British colonial rule when the Criminal Tribes Act of 1871 categorised the entire transgender community as "criminals" who were "addicted" to committing serious crimes. They were arrested for dressing in women's clothing or dancing or playing music in public places, and for indulging in gay sex.
After Independence, the law was repealed in 1949, but mistrust of the transgender community has continued. Even today, they remain socially excluded, living on the fringes of society, in ghettoised communities, harassed by the police and abused by the public. Most make a living by singing and dancing at weddings or to celebrate child birth, many have moved to begging and prostitution.
It is hoped that the landmark court ruling will help bring them into the mainstream and improve their lot.
Rights groups say they often face huge discrimination and that sometimes hospitals refuse to admit them.
They have been forced to choose either male or female as their gender in most public spheres.
"Recognition of transgenders as a third gender is not a social or medical issue but a human rights issue," Justice KS Radhakrishnan, who headed the two-judge Supreme Court bench, said in his ruling on Tuesday.
"Transgenders are also citizens of India" and they must be "provided equal opportunity to grow", the court said.
"The spirit of the Constitution is to provide equal opportunity to every citizen to grow and attain their potential, irrespective of caste, religion or gender."
The judges asked the government to treat them in line with other minorities officially categorised as "socially and economically backward", to enable them to get quotas in jobs and education.
"We are quite thrilled by the judgement," Anita Shenoy, lawyer for the petitioner National Legal Services Authority (Nalsa), told the BBC.
"The court order gives legal sanctity to the third gender. The judges said the government must make sure that they have access to medical care and other facilities like separate wards in hospitals and separate toilets," she said.
Prominent transgender activist Laxmi Narayan Tripathi, who was among the petitioners in the case, welcomed the judgement, saying the community had long suffered from discrimination and ignorance in the traditionally conservative country, reports the Agence France-Presse news agency.
"Today, for the first time I feel very proud to be an Indian," Ms Tripathi told reporters outside the court in Delhi.
In 2009, India's Election Commission took a first step by allowing transgenders to choose their gender as "other" on ballot forms.
But India is not the first country to recognise a third gender. Nepal recognised a third gender as early as in 2007 when the Supreme Court ordered the government to scrap all laws that discriminated on the basis of sexual orientation or gender identity. And last year, Bangladesh also recognised a third gender.
Tuesday's ruling comes after the Supreme Court's decision in December which criminalised gay sex by reversing a landmark 2009 Delhi High Court order which had decriminalised homosexual acts.
According to a 153-year-old colonial-era law – Section 377 of the Indian Penal Code – a same-sex relationship is an "unnatural offence" and punishable by a 10-year jail term.
Legal experts say Tuesday's judgement puts transgender people in a strange situation: on the one hand, they are now legally recognised and protected under the Constitution, but on the other hand they may be breaking the law if they have consensual gay sex.