Gov. Jerry Brown on Sunday signed a bill that prevents local governments from banning male circumcision, a law that was conceived earlier this year after a ballot measure that would outlaw the practice appeared headed to San Francisco voters.

Proponents of the ballot measure said the practice should be stopped because it caused "painful and damaging surgery to an unwilling patient." They also questioned arguments that circumcision has medical benefits.

But Assemblyman Mike Gatto, D-Burbank, jumped into the controversy in July, introducing AB768. He said he wanted to prevent local governments from creating their own "patchwork of regulations" covering medical procedures in the state. The Legislature passed the bill last month and sent it to Brown's office.

Several groups, including the Jewish Community Relations Council, had filed suit to stop the measure. In late July, a San Francisco Superior Court judge ordered the measure taken off the ballot, saying it was "expressly pre-empted" by state law and served "no legitimate purpose."

Matthew Hess, an activist behind the attempted ban in San Francisco, said Sunday that California had "taken a big step backward. ... Circumcision is elective surgery that an adult should be allowed to choose for himself."