Taiwan's constitutional court has ruled that same-sex couples have the right to legally marry, in the first such ruling to be handed down in an Asian country.

The court, known as the Judicial Yuan, said current marriage laws were "in violation of both the people's freedom of marriage ... and the people's right to equality", and it gave two years for legal amendments to allow same-sex marriage.

"If relevant laws are not amended or enacted within the said two years, two persons of the same sex who intend to create the said permanent union shall be allowed to have their marriage registration effectuated," the court said.

Lesbian, gay, bisexual and transgender rights activists had harboured high hopes their years of campaigning for same-sex marriage would win the court's backing.

The ruling Democratic Progressive Party that swept national elections in the self-ruled island last year supports the change.

The ruling clearing the way for same-sex marriage is the first in Asia, where socially conservative attitudes largely hold sway.

But Taiwan has a reputation as a beacon of liberalism in the region.

"Sexual orientation is an immutable characteristic that is resistant to change," the court said.

"Furthermore, the freedom of marriage for two persons of the same sex, once legally recognised, will constitute the collective basis, together with opposite-sex marriage, for a stable society," it said.