India puts an end to the ban on colonial life in the colonial era

(File) India's Supreme Court has put an end to a ban on gay sex.

India's Supreme Court on Thursday annulled a colonial-era ban on gay sex in the middle of years of legal battles.

"The law had become a weapon of harassment for the LGBT community," Supreme Court Chief Justice Dipak Misra said in announcing the historic verdict.

Section 377 of the Indian penal code, promulgated by British rulers in 1861, prohibited "carnal relations against the order of nature."

Activists have been fighting the ban since the 1990s, suffering several judicial setbacks before the verdict on Thursday that sparked celebrations among lesbian, gay, bisexual and transgender groups across the South Asian nation.

Members of the LGBT community embraced and cried as the news of the verdict spread.

"I have no words, it has taken a long time to arrive, but finally I can say that I am free and have the same rights as everyone else," said Rama Vij, a university student wearing a colored handkerchief.

Gay sex has long been taboo in conservative India, especially in rural areas where homophobia is widespread.

The Delhi Supreme Court decriminalized homosexual sex in 2009, but the Supreme Court reinstated legal sanctions in 2014 after a successful appeal by religious groups.

According to official data, in 2016 2,187 cases were registered under Section 377 in the category of "non-natural crimes".

Seven people were convicted and 16 acquitted.