Sri Lanka's highest court has shot down a government bill seeking gender equality, arguing it could set a legal precedent for the decriminalisation of homosexuality and same-sex marriage, parliament said Tuesday.

The three-judge bench of the Supreme Court ruled the bill, which sought to tackle sexism and violence, undermined conservative values on the majority-Buddhist island.

"It is clear that when this bill becomes law it becomes possible for any interested party to claim legal status for same-sex marriages," presiding judge P. Padman Surasena wrote, backed by the two other judges.

"This is something which neither our constitution nor our culture has envisaged."

Surasena said the de-criminalisation of homosexuality and the recognition of same-sex marriages would have "significant cultural and moral implications".

The court said recognising "persons with different gender identities" would also violate the constitution.

The Gender Equality Bill seeks to enshrine in law equal opportunities to all "irrespective of differences in sex or gender identity".

President Ranil Wickremesinghe urged lawmakers to appoint a select committee to overrule the judiciary.

"We are being asked to accept it (the ruling), which this house can't," Wickremesinghe told parliament.

He said there was a judicial precedent that allowed parliament to remove discriminatory laws.

Wickremesinghe argued that the court ruling undermined previous progressive decisions, calling their decision "judicial cannibalism".

Homosexual sex is a criminal offence in Sri Lanka, whose penal code dates from British colonial rule.

Although prosecutions are rare, activists say the anti-homosexuality law has been used by police to discriminate against the LGBTQ community.