Austria's top court has ruled that current laws are discriminatory and must be lifted by 2019.
It said however that the current rules would remain in place until December 31, 2018 unless Austria's parliament changes the law before then.
But a lesbian couple denied the right to marry who brought the case, plus four other couples who also filed a complaint, can tie the knot now, it said.
In April 2001 the Netherlands became the first country in the world to allow gay and lesbian couples to marry in a civil ceremony.
Not including Austria, 15 European countries have followed including Belgium, France, Britain (but not Northern Ireland), Ireland and -- since earlier this year -- Germany.
Others such as Hungary, Italy and the Czech Republic only allow same-sex civil partnerships, a kind of marriage-light, as was the case in Austria until the new ruling.
Many ex-Communist eastern European countries -- including Bulgaria, Poland, Romania and Slovakia -- still deny homosexuals the right to marry or enter into unions.
In Austria a 2009 law allowed same-sex couples to enter into civil partnerships but stopped short of allowing them to marry.
However, the new court ruling said that recent changes including allowing gay couples to adopt children meant that the two institutions were now largely identical.
As a result, "the distinction between marriage and registered partnership cannot be upheld without same-sex couples being discriminated against," it said.
It also ruled that civil partnerships must also be open to heterosexual couples and not just same-sex ones as at present.
Helmut Graupner, a lawyer for the two women who brought the case, said that this is the first time that a European court has lifted a ban on same-sex marriage.
"Accordingly Austria is the first European country to recognise marriage equality for same-gender couples as a fundamental human right. All the other European states with marriage equality introduced it (just) the political way," he said on Facebook.
"The Austrian Constitutional Court gave the most wonderful Christmas present one could imagine to loving couples," he added.
The ruling comes as Sebastian Kurz's conservative People's Party (OeVP) and the far-right Freedom Party (FPOe) negotiate forming a coalition government following October elections.
In June, just after Austria's neighbour Germany changed the rules, both parties voted in parliament against proposals to change the law on same-sex unions.