The ruling by the Council of State relates to the Mediterranean resort of Villeneuve-Loubet, one of more than a dozen French towns that have imposed such bans.

The burkini ban has shone a light on secular France's long-standing difficulties integrating its Muslim population and dealing with the aftermath of a series of Islamist attacks.

The court said in a statement the decree to ban burkinis in Villeneuve-Loubet "seriously, and clearly illegally, breached the fundamental freedoms to come and go, the freedom of beliefs and individual freedom."

The lawyer representing the League of Human Rights campaign group which had challenged the ban in Villeneuve-Loubet told reporters the ruling meant all town halls would need to reverse their bans. The group argued the bans contravened civil liberties.

Also Read: Troubled Europe Debates Burqas, Niqabs And Burkinis

But one mayor in Corsica said he would not suspend his own ban, showing that the ruling will not put a quick end to the heated controversy that has already filtered into early campaigning for the 2017 presidential election.

"There's a lot of tension here and I won't withdraw my decree," Sisco mayor Ange-Pierre Vivoni told BFM TV.

The issue has also made French cultural identity a hot-button issue along with security in political debates ahead of next April's presidential election.

Prime Minister Manuel Valls robustly defended the burkini ban on Thursday while some ministers criticized it, exposing divisions within the government as campaigning begins.

Former president Nicolas Sarkozy said on Thursday he would impose a nationwide ban on burkinis if elected as he seeks to position himself as a strong defender of French values and tough on immigration.

"This is a slap for the prime minister and a kick up the backside for Sarkozy," Abdallah Zekri, secretary general of the French Muslim Council (CFCM) said of the ruling. "We're satisfied with this."

Socialist Party spokesman Razzy Hammadi told BFM TV he hoped the ruling "will put an end to this nasty controversy".