Image caption Protesters disrobed in front of San Francisco city hall in protest last week

San Francisco lawmakers have voted to ban nudity in public places, ending a bitter dispute with a group of nudists.

City officials voted 6-5 in favour of banning anyone over five from exposing "his or her genitals, perineum or anal region" in most public locations.

"Freedom, expression and acceptance does not mean anything goes under any circumstances," district supervisor Scott Wiener said.

The ruling allows exceptions for certain street fairs and events.

A federal lawsuit has already been filed arguing the proposal infringes on free speech rights.

I think it's a caricature of what San Francisco is about Scott Wiener, District supervisor

"I'm concerned about civil liberties, about free speech, about changing San Francisco's style and how we are as a city," Supervisor John Avalos said after the vote.

Mr Avalos and Mr Wiener both sat on the Board of Supervisors, which narrowly passed the measure.

The ordinance plan follows complaints about a growing number of naked men who have been gathering in a public plaza in the city's Castro district, a hub for the gay community.

Media playback is unsupported on your device Media caption Supervisor Scott Wiener: "People have been taking their clothes off and hanging out seven days a week and it's gone too far"

The city had previously passed a law requiring a piece of cloth between a nude resident and a public seating place. But after that proposal was passed the number of nude men who flocked to the plaza increased.

"The Castro and San Francisco in general, is a place of freedom, expression and acceptance," Mr Wiener said.

But he added: "Our public spaces are for everyone and as a result it's appropriate to have some minimal standards of behaviour."

Under the new law, a first offence would carry a maximum $100 (£62) fine, but prosecutors could also penalise offenders up to $500 and hand down a year in jail.

Last week, about two dozen people undressed in front of San Francisco city hall in protest at the proposed ban.

One demonstrator, McCray Winpsett, 37, told the Associated Press the ordinance went too far in undermining a tradition "that keeps San Francisco weird".