Image copyright AFP Image caption The debate over whether to legalise same-sex marriage has divided Taiwan

Taiwan's top judges have ruled in favour of gay marriage, paving the way for it to become the first place in Asia to legalise same-sex unions.

The highest court ruled that current laws preventing members of the same sex from marrying violated their right to equality and were unconstitutional.

It gave parliament two years to amend existing laws or pass new ones.

Wednesday's landmark decision came as the LGBT community faces increasing persecution in the region.

In a press release following the ruling, the court said that "disallowing two persons of the same sex to marry, for the sake of safeguarding basic ethical orders" constituted a "different treatment" with "no rational basis."

The court concluded that "such different treatment is incompatible with the spirit and meaning of the right to equality" as protected by Taiwan's constitution.

Taiwanese couple: 'We're just like any other parents'

Analysis: Cindy Sui, Taipei

The court's ruling means Taiwan's parliament will have to amend existing laws or pass new legislation.

But it's still unclear how far parliament will go.

The LGBT community hopes legislators will simply amend the existing marriage laws to include same-sex couples, which would grant them the same rights enjoyed by opposite-sex couples, including in cases of adoption, parenting and inheritance - and making decisions for each other in medical emergencies.

However, they fear parliament won't do that and will instead pass a new law that recognises same-sex marriages but gives them only some rights, not equal treatment in all matters.

Religious and parents groups opposed to gay marriage say they will lobby parliament not to pass any laws on legalisation. They argue such an important matter that affects the whole of society shouldn't be decided by just a few grand justices, but by the people in a referendum.

Both sides will now focus their attention on persuading the legislators.

Self-ruled Taiwan, over which China claims sovereignty, is known for its liberal values and holds the biggest annual gay pride event in the region.

Image copyright Reuters Image caption Colourful costumes, including swimsuits, wedding dresses and loin cloths, were on display

Momentum for marriage equality has been building since last year, when President Tsai Ing-wen, who is openly supportive of the move, came to power.

But the debate has prompted a backlash, with mass protests by conservatives in recent months.

Now that the 14-judge panel has ruled in favour of the legal challenge, the parliament, known as the Legislative Yuan, will begin the process of amending the laws.

It can either legalise same-sex marriage or introduce new separate civil partnership legislation.

If legislators fail to meet the court's two-year deadline, it said same-sex couples could register to marry based on its ruling.

A bill to legalise same-sex marriages is already making its way through parliament, but that process has slowed because of opposition from traditionalists, who do not want Taiwan to become the first place in Asia to allow such weddings.