The Council of State's ruling against Villeneuve-Loubet is expected to set a precedent for the dozens of other French towns that have also laid down such bans.
But it is unlikely to put an end to a controversy that has shown the difficulties France has had integrating its Muslim population.
The issue also highlights the problems Muslims in France have experienced following a series of deadly attacks carried out by Islamist militants against the public in the past 20 months, including in Parais and Nice.
Conservative and far-right politicians have asked for a law to ban burkinis nationwide.
The court said in a statement the decree to ban burkinis in Villeneuve-Loubet "had seriously infringed, in a manner that was clearly illegal, fundamental liberties such as the freedom to come and go, religious freedom and individual freedom."
The burkinis did not pose any threat to public order in Villeneuve-Loubet, the court said.
The burkini issue has filtered into early campaigning for the 2017 presidential election and early reaction to the ruling showed that supporters of the ban, who include ex-president Nicolas Sarkozy, would not let it go.
Some of Sarkozy's closest supporters said they would propose in September a draft law that would allow mayors to ban burkinis.
"We need a law," Nice deputy mayor Christian Estrosi said on Twitter.
Since conservatives do not have a majority in parliament and such a bill would have no chance of being adopted, Estrosi suggested that Socialist Prime Minister Manuel Valls, who himself backed the bans, come up with a draft law.
Valls defended the burkini ban on Thursday while some ministers criticized it, exposing divisions within the government as campaigning begins.
While rulings by the Council of State do set precedents, several mayors said they would not suspend their own bans and rights groups said they would bring them to courts, meaning more lawsuits are expected. The Council of State has the final word on such matters.
"There's a lot of tension here and I won't withdraw my decree," Sisco mayor Ange-Pierre Vivoni told BFM TV, arguing that in his Corsica town the ban would be justified on security grounds.
"FRANCE HAS CHANGED"
The controversy has also made French cultural identity a hot issue in political debates ahead of next April's presidential election.
Abdallah Zekri, secretary general of the French Muslim Council (CFCM) said of the ruling: "This is a slap for the prime minister and a kick up the backside for Sarkozy."
A spokesman for the ruling Socialist Party and the rector of the Great Mosque of Paris, Dalil Boubakeur welcomed the ruling and said they hoped it would calm things down.
But the mayor of Villeneuve-Loubet, Lionnel Luca, of Sarkozy's Les Republicains party, said it would heighten tensions.
"We need to decide if we want a smiley, friendly version of sharia on our beaches or if we want the rules of the (French) republic to be implemented," he said, referring to the Islamic legal and moral code of sharia.
Hakim, a 42-year-old trader of Algerian origin said that while he welcomed the ruling it did not really reassure him.
"The decision by the Council of State is normal. France is a democratic country, there is justice and this is good for Muslim women," he said after Friday prayers at Paris' main mosque.
But he added: "It is because of all these problems that I am thinking of leaving France and returning to Algeria after over 30 years here. It was not like this before, France has changed and it is not easy for us."