HOUSTON — The predominantly black Third Ward here, a historic and struggling community, seemed like the kind of precinct that would be sympathetic to a broad ordinance outlawing discrimination based on factors such as race, religion and sexual orientation.

But at a polling site in the Cuney Homes public housing complex here on Tuesday, the talk among voters was not about discrimination. Picking up on an ad campaign run by a coalition of pastors, social conservatives and Republicans opposed to the measure, they voiced concerns as parents that it would let men claiming to be women enter women’s bathrooms and attack.

“I got three daughters,” said Todd Ward, a city worker who had voted against the ordinance. “You have too much child molestation going on. It’s equal rights, but there’s not an equal right for me to go into a women’s bathroom. That’s common sense.”

More than a year ago, when Mayor Annise D. Parker and her supporters first proposed the ordinance and steered it through the City Council, they expected it to be welcomed in a diverse city that had become, with Ms. Parker’s election in 2009, the nation’s first big city to elect an openly gay or lesbian mayor.