BERLIN (AP) - Austria's Constitutional Court has ruled that same-sex couples will be allowed to marry by the beginning of 2019, bringing the country in line with more than a dozen other western European nations.

In a ruling announced Tuesday, the court said that the words "two people of different sex" will be removed from the law on marriage at the end of 2018 on the grounds that the distinction is discriminatory. Same-sex couples will be able to marry after that, unless the government decides to change the laws earlier.

Same-sex couples in Austria, a predominantly Roman Catholic nation of some 8.7 million people, have been allowed to enter civil partnerships since 2010. Until now, however, they haven't been able to marry.

FILE - In this June 13, 2008 file photo the Austrian Constitutional Court with President Gerhart Holzinger meets in Vienna, Austria. Austria's Constitutional Court has decided on Tuesday, Dec. 5, 2017 that same-sex couples will be allowed to marry by the beginning of 2019, ruling that the existing laws are discriminatory. (AP Photo/Ronald Zak, file)

The Constitutional Court took up the issue following a complaint from two women who were already in a partnership but were refused permission to enter a formal marriage by authorities in Vienna.

The court said that civil partnerships will remain an option after the law is changed, and will then also be open to straight couples. It noted in its ruling that marriage and civil partnerships have become increasingly similar in a legal sense in recent years, with same-sex couples allowed to adopt children.

In a statement, it 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 already been legalized in 15 countries in western Europe, including in Germany, which until this year was the biggest holdout. A similar number of other European countries have some sort of same-sex unions or civil partnerships.

Helmut Graupner, a lawyer for the two women who brought the case, wrote in a Facebook post that "today is a truly historic day." He said the Austrian court was the first in Europe to reject a marriage ban for same-sex couples, while other countries legalized gay marriage through political means.

The two parties negotiating to form a new government after Austria's October election, the conservative Austrian People's Party and the right-wing Freedom Party, have so far opposed gay marriage. The center-left Social Democrats, who lead the outgoing government, are in favor.