SYDNEY, Australia — Australia ’s highest court on Thursday struck down a landmark law that had begun allowing the country’s first same-sex marriages .

More than two dozen same-sex couples will now have their marriages annulled less than a week after their weddings.

The federal government had challenged the validity of a law passed in October in the Australian Capital Territory that allowed same-sex marriages in the nation’s capital, Canberra, and its surrounding area starting last Saturday.

The federal government’s lawyer had argued that having different marriage laws in various Australian states and territories would create confusion.

The High Court unanimously ruled that the territory’s law could not operate concurrently with the federal Marriage Act, which was amended in 2004 to define marriage as between a man and a woman.

“The Marriage Act does not now provide for the formation or recognition of marriage between same-sex couples,” the court said in a statement. “The Marriage Act provides that a marriage can be solemnized in Australia only between a man and a woman. That act is a comprehensive and exhaustive statement of the law of marriage.”

Rodney Croome, national director of the advocacy group Australian Marriage Equality, said his group knew of about 30 same-sex couples who had married since Saturday, though the actual number may be slightly higher. The court decision essentially nullifies their marriages, as it means the law under which they were wed was invalid.

In its decision, the court wrote that the federal government was responsible for deciding whether same-sex marriage should be legalized. The ruling means that no Australian state or territory can make that decision, said Anne Twomey, a Sydney University constitutional lawyer.

Lyle Shelton, managing director of Australian Christian Lobby, which opposes same-sex marriage, praised the ruling, saying common sense had prevailed.

Prime Minister Tony Abbott opposes same-sex marriage, and his coalition has blocked two bills that would have allowed legal recognition of same-sex unions.