Italy's highest administrative court annulled a ruling by a lower court which had earlier found in favour of cities from Rome to Naples and Milan which had registered such marriages despite the fact that Italy has no legal framework for gay unions.
Interior Minister Angelino Alfano, who issued an order last year banning the practice, applauded the latest ruling, saying it showed he was right to take a stand despite having provoked "controversy, sometimes violent aggression and a hail of appeals".
"Let us be clear. Marriage between two people of the same sex is not contemplated under Italian law, therefore the transcriptions made by local mayors are illegal," he said.
The decision was met in some quarters with anger if not surprise in a country where the Catholic Church - opposed to gay marriage - plays an influential role in politics.
The judge behind the ruling was forced to defend himself amid accusations he had been swayed by his Catholic beliefs, which he publicly declared on his Twitter profile, Italian media reported.
Legislators on the left joined gay rights campaigners in expressing frustration.
Foreign ministry undersecretary Benedetto Della Vedova said it was "a victory for none and a defeat for all", insisting that Italy "remains at the starting post as regards gay rights, which urgently need to be regulated".
A bill introducing civil unions for same-sex couples is currently being examined by parliament but has met fierce opposition.
Story continues below…
In October 2014, Rome's centre-left mayor Ignazio Marino registered 16 gay marriages performed outside Italy, saying they had the same rights as heterosexual couples who marry abroad. The move elicited an angry statement from the national association of bishops and calls from the right wing for his resignation.
Recognizing a marriage means the couple involved have rights to everything from shared health insurance to inheriting pensions.