Austria's Constitutional Court has decided that same-sex couples will be allowed to marry by the beginning of 2019, ruling that the existing laws are discriminatory.
The move brings Austria into line with many other European nations including Germany, France, Britain and Spain.
Same-sex couples in Austria have been allowed to enter legal partnerships since 2010, but until now have not been able to marry.
The Constitutional Court examined a 2009 law following a complaint from two women who were refused permission to enter a formal marriage by authorities in Vienna.
It said in a ruling published on Tuesday that restrictions on same-sex marriage will be lifted at the end of 2018 unless the government does so itself earlier.
The Constitutional Court said that civil partnerships will remain an option after the law is changed, and will then be open to straight couples.
In a statement, Austria's Constitutional Court said "the distinction between marriage and civil partnership can no longer be maintained today without discriminating against same-sex couples," adding that keeping the two institutions separate suggests that "people with same-sex sexual orientation are not equal to people with heterosexual orientation".
Gay marriage has been legalised in many countries in western Europe, most recently in Germany, where there was stiff opposition to the change for several years.
Almost a dozen other European countries have some sort of same-sex unions or civil partnerships, according to the Pew Research Centre.
The conservative People's Party and the far-right Freedom Party, which are in negotiations for a government coalition and both oppose same-sex marriage, could not immediately be reached for comment.
The Homosexual Initiative Vienna (HOSI) welcomed the decision. "We are very happy," said HOSI chairman Christian Hoegl. "We want to use the opportunity for a renewed call for a fundamental reform of marriage."
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies