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.
Hundreds of supporters of same-sex marriage gathered in the street next to the island's parliament to celebrate the decision, holding colourful umbrellas to ward off a drizzle.
"This ruling has made me very happy," said Chi Chia-wei, a veteran gay rights activist who had petitioned the court to take up the issue.
The ruling clearing the way for same-sex marriage is the first in Asia, where socially conservative attitudes largely hold sway.
A lawyer said the ruling made clear that same-sex couples had the same marriage rights as opposite-sex couples.
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 in its ruling.
"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.