Australia's highest court struck down a landmark law on Thursday that had begun allowing the country's first gay marriages, shattering the dreams of more than two dozen same-sex newlyweds whose marriages will now be annulled less than a week after their weddings.

The federal government had challenged the validity of the Australian Capital Territory's law that had allowed gay marriages in the nation's capital and its surrounding area starting last Saturday.

For Ivan Hinton, who married his partner Chris Teoh on Saturday, the result was heartbreaking. The couple just received their marriage certificate on Wednesday and immediately applied to change their surnames to Hinton-Teoh. Still, Hinton said he doesn't regret going through with the wedding, and will always consider Teoh his husband.

"This was an unprecedented and historic opportunity," he said. "I wouldn't have missed it for the world."

The federal government's lawyer had argued that having different marriage laws in various Australian states and territories would create confusion. The ACT, which passed the law in October, said it should stand because it governs couples outside the federal definition of marriage as being between members of the opposite sex.

The High Court unanimously ruled that the ACT'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 Marriage Act provides that a marriage can be solemnised in Australia only between a man and a woman," the court said in a statement issued alongside its ruling. "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 knows of about 30 same-sex couples who have married since Saturday, though the actual number may be slightly higher. The ruling means their marriages are now nullified.

Outside the court in Canberra, a tearful Croome, flanked by several same-sex couples who were married in the past week, said the ruling was a defeat for marriage equality but there had been a greater victory this week.

"And that victory was the nation saw for the first time, I believe, what is really at the core of this issue — they've seen that marriage equality is not about protest or politics or even about laws in the constitution, ultimately. Marriage equality is about love, commitment, family and fairness," Croome said.

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

As for the ruling's impact on the newly-wedded couples, Shelton said it was "really sad that they were put in a position" in which they were allowed to marry before the court handed down its judgment.

"But I guess they knew as they went into these arrangements that the decision may not go their way," he said.

Prime Minister Tony Abbott opposes gay marriage and his coalition blocked two federal bills last year that would have allowed legal recognition of same-sex partnerships.

The ruling comes a day after India's Supreme Court struck down a 2009 lower court decision to decriminalize homosexuality, dealing a blow to gay activists who have fought for years for the chance to live openly in India's deeply conservative society.

Gay marriage has legal recognition in 18 countries as well as 16 U.S. states plus the District of Columbia.