Flags and kites fill the sky on a Memorial Day weekend at the beach in Ocean City, Md. (Bill O'Leary/Post)

A federal judge has ruled that Ocean City can continue to enforce a law banning female bare chests on the beach as the resort town defends itself in a lawsuit challenging the legislation.

Five Maryland woman have sued the town for passing an emergency ordinance in summer 2017 that allows men, but not women, to be shirtless on the beach. The women, including “topfreedom” advocate Chelsea Eline, say the ordinance violates equal protection laws and is sexist.

But Ocean City officials said the ordinance was necessary to protect the family-friendly image of the town that attracts 4 million people to its beaches annually. The town defended the constitutionality of the ordinance by saying bare female breasts in public were “still seen by society as unpalatable.”

At a court hearing this month, both sides sparred over whether the law “reflected public sensibilities” in Ocean City and who would be the best person to judge those sensibilities. A 1991 federal appeals court ruling allowed a similar ban, finding that the government had a legal right to force women, but not men, to keep their tops on because exposing female breasts in public is considered offensive by many.

“Although Plaintiffs believe public sensibilities have changed to the point of ready acceptance by the public of bare-breasted females in public — other than for breast-feeding infants — they failed to counter the quite convincing evidence presented by Ocean City to the contrary,” U.S. District Judge James K. Bredar wrote in his denial of a preliminary injunction made public Thursday. “That does not mean that public sensibilities recognized today will always be regarded as appropriate but, for now, the Court has seen no evidence that public sensibilities are not what Ocean City’s representatives say they are in the ordinance.”

Devon Jacob, an attorney for Eline and the four other woman who have challenged the Ocean City ban, said they were not discouraged by the judge’s decision.

“A preliminary injunction is an extraordinary remedy that is rarely granted,” Jacob said in a statement. “The fact that the Court denied the request on a very limited record is not at all surprising.”

Eline, a regular beachgoer who runs a blog called Breasts Are Healthy, asked the city last summer to give the beach patrol and police officers clearer instructions so women could sunbathe bare-chested without confrontation. The beach patrol issued a memo that generated national attention, instructing employees not to “approach the topless woman, even if requested to do so by the complainant or other beach patrons.”

Some interpreted the memo to mean that Ocean City would allow female bare chests on the beach, erupting into a national controversy. Ocean City officials then passed an emergency ordinance banning bare female chests in public.

The Maryland Attorney General’s Office said the law is legally sound, but Eline sued.

In a Thursday statement, Ocean City Mayor Rick Meehan said city officials are “very pleased by the court’s ruling.”

“Since this question of the legality of female bare-chestedness first arose in 2016, we have worked hard and will continue to work hard to preserve the family-friendly Ocean City experience our residents and visitors expect,” the mayor’s statement said.

Bruce F. Bright, an attorney for the town, said the judge’s decision follows “prevailing case law throughout the country.”

“As Judge Bredar determined in his ruling, the ordinance is an expression of the views and aspirations of the community as determined by Ocean City’s duly elected representatives, and it serves the important governmental objective of protecting public sensibilities on the matter,” Bright said.

Still, the lawsuit continues and Jacob said he and his clients will address the court’s concerns “so that the Court will be able to issue a final decision that recognizes that men and women are equal under the law, and that a person’s civil rights do not yield to the sexist ideology of 150 people and their government representatives.”