PARIS — The mayor of the French resort city of Cannes has barred women from bathing on public beaches in swimsuits that reveal too little skin.

At issue are the full-body, head-covering garments worn in the water by some Muslim women, which have been nicknamed burkinis, an amalgam of burqa and bikini. The mayor’s ban has drawn protests from French Muslims who say it is discriminatory.

Critics of the ban say it risks deepening rifts with France’s Muslims. It is the latest example of the long-running tensions between France’s forceful — some say inconsistent — commitment to secularism and the desire of many Muslims to express traditional values like modesty through their attire.

The mayor’s ordinance, which runs until Aug. 31, bars people from entering or swimming at the city’s public beaches in attire that is not “respectful of good morals and secularism” and that does not respect “rules of hygiene and security.” Offenders risk a fine of 38 euros, or about $42.

Why are burkinis against the rules? “Beach attire that ostentatiously displays a religious affiliation, while France and places of worship are the target of terrorist acts, is likely to create risks to public order,” the ordinance says.

The mayor, David Lisnard, said in an interview with the newspaper Nice-Matin that the decree was intended as a protective measure and that he was not banning “the veil, the kippa or the cross” on city beaches.

The ordinance states that religious freedom can be curtailed for security reasons and does not mention any particular faith. But Mr. Lisnard told the newspaper that the ban was directed specifically at Muslim attire, even though Cannes officials acknowledge that the number of women who swim in such clothing is “marginal.”

“If a woman goes swimming in a burkini, that could draw a crowd and disrupt public order,” Mr. Lisnard said. “It is precisely to protect these women that I took this decision. The burkini is the uniform of extremist Islamism, not of the Muslim religion.”

Mr. Lisnard said the measure could also apply to women wearing a traditional Indian sari, because such a garment could hamper rescue efforts in the water.

The decree was the latest decision made in the name of laïcité — the French term for separation of church and state — that targets Muslim clothing, a regular point of contention in France. Politicians differ deeply over how to define laïcité; some acknowledge that it is increasingly used to justify measures that single out Muslims, rather than to keep government out of all religion and vice versa, the principle’s original intent.

A 2004 law banned the wearing of religious attire in public schools, and since then, many of the French government’s prohibitions on public displays of religious belief have centered on Muslim women. Their faith is visible in what they wear (it is less evident with most Muslim men), and, on top of that, many French people are particularly disturbed by the sight of a woman who covers her head and body.

The restrictions have also arisen at a time of renewed emphasis on the assimilation of people from immigrant backgrounds and amid rising fears of terrorism.

The French emphasis on keeping religious attire out of public life can at times seem strange to foreigners. At the Olympic Games in Rio de Janeiro, several Muslim women have competed in sportswear that cover their hair and neck. Nor is head-covering swimwear used exclusively by Muslim women; face-covering swimsuits have been spotted in China and other places, worn by beachgoers worried about too much sun.

The measure in Cannes was enacted on July 28, two weeks after the attacks in Nice, roughly 15 miles to the east, in which 85 people were killed by a truck driver; and two days after a priest was killed by two men with knives in St.-Étienne-du-Rouvray, Normandy. Militants professing loyalty to the Islamic State were behind each attack.

The Collective Against Islamophobia in France said in a statement Friday that Mr. Lisnard’s arguments were “shocking” and that it was filing a legal complaint against the ordinance.

While wearing a face-covering veil in public or a head scarf in state elementary and high schools is banned by French law, there are otherwise no national restrictions on wearing religious clothing or symbols in public.

In 2014, the mayor of Wissous, in the southern suburbs of Paris, barred women in head scarves from a temporary beach, but courts struck down the ban.

Nice-Matin reported on Friday that Villeneuve-Loubet, a coastal town about eight miles southwest of Nice, enacted a ban last week similar to the one in Cannes.

“This is just a way for politicians to hide their inability to handle security in the face of terrorism,” said Feiza Ben Mohamed, a spokeswoman for the Fédération des Musulmans du Sud, a Muslim association in southern France.

The beach bans echoed a decision this month by the mayor of Les Pennes-Mirabeau, about 10 miles north of Marseille, to prohibit a private gathering of women and children at a local water park.

The gathering was organized by a women’s association from Marseille that had booked the park for a full day, told participants that male lifeguards would be present, and suggested that women wear swimsuits that fully covered their bodies, or at least from the knees to the chest. Local right-leaning and far-right politicians criticized the event as promoting extremist Islam.

The mayor of Les Pennes-Mirabeau said the event was banned because of potential risks to public security.

Correction:

Because of an editing error, an article on Aug. 13 about a ban on the wearing of the full-body coverings nicknamed burkinis on the beaches of Cannes, France, referred imprecisely to French restrictions on clothing. A 2010 law that bans the wearing of most face coverings in public does not make any reference to religion, but the law has been widely interpreted to apply to burqas and niqabs, two garments often worn by Muslim women.