Rita Palomarez, left, and Linda Rodriguez pray during an election watch party attended by opponents of the Houston Equal Rights Ordinance. (Brett Coomer/Houston Chronicle via AP)

The defeat of an equal rights ordinance in Houston this week was a setback for the gay rights movement, which had a banner year with the Supreme Court’s decision to legalize same-sex marriage.

But as Tuesday’s vote showed, the movement is still finding its footing on its next big priority: ending discrimination against gay and transgender people.

Voters in Houston, a Democratic-leaning city, decisively rejected the nondiscrimination ordinance, with 61 percent of voters against it and 39 percent in favor. Supporters cited a number of factors for the loss, but voters appeared to be heavily swayed by opponents’ argument that the measure would allow men, particularly sexual predators, to enter women’s restrooms.

That argument is not new. This year, eight states considered bills that would have made it a crime for someone to enter restrooms that do not match their biological sex. While none of them passed, transgender rights groups expect more such bills to be introduced next year.

Across the country, school districts have struggled to balance the needs of transgender students’ use of the appropriate bathroom and locker room with social mores and parental fears. On Monday, federal education authorities found that an Illinois school district violated sex-discrimination laws by barring a transgender student from the girls’ locker room and girls’ sports teams.

The issue has stymied efforts to gain what gay rights groups consider to be comprehensive anti-discrimination protections for gay and transgender people: laws that bar unequal treatment in employment, housing and public accommodations such as shops and restaurants. In Massachusetts, a typically liberal state that was the first to legalize same-sex marriage, efforts to include gender identity as a protected class in public accommodations have failed.

Activists say they expect opponents to rachet up the rhetoric on bathrooms, emboldened by the Houston vote.

“We know there’s more work to do,” said Mara Keisling, executive director of the National Center for Transgender Equality, who said she thinks the bathroom issue will dominate the organization’s work for the next few years. The focus during that time, she said, will be “educating the American public that we are good, decent people who are being attacked by — I don’t know how else to say it — lying extremists.”

Opponents of anti-discrimination measures say that the bathroom issue is real and that such measures put women at risk. In a startling TV ad aired during the Houston campaign, a young girl wearing knee socks and a backpack is stalked in a public restroom by an older man as a voice warns that “any man at any time could enter a women’s bathroom by claiming to be a woman that day.”

“From a purely common-sense perspective, it’s a big problem when you open restrooms, locker rooms, shower facilities where people are in various states of undress to people of the opposite sex,” said Christiana Holcomb, legal counsel for the Alliance Defending Freedom, a conservative legal organization that has advocated against the Houston ordinance and other efforts to expand gay and transgender rights. “It looks like an open invitation for people to use these laws for nefarious purposes.”

Gay and transgender rights activists call these warnings fear-mongering and stereotyping, and compare them to past efforts to portray gay and lesbian adults as “recruiters” for the “gay agenda.” In 2008, opponents of same-sex marriage in California aired a TV ad in which a pigtailed girl bounds home to proudly tell her mother what she learned in school: “I learned how a prince married a prince and I can marry a princess!”

The ad famously and successfully played on parents’ worst fears about same-sex marriage, said Matt McTighe, executive director of Freedom for All Americans, a gay rights group focused on passing anti-discrimination measures across the country. It took years of public outreach to overcome such fears, he said.

Now, the movement must take a similar approach with transgender people, he said, introducing them to average Americans as their neighbors, co-workers and friends. To that end, Freedom for All Americans has launched a campaign called the Transgender Freedom Project, which will identify and educate transgender people in small towns and big cities who can speak to the media, stand on rally stages and make their case personally to lawmakers.

“It’s the personal stories that won us the freedom to marry,” he said. “It’s going to be those personal stories that, again, win the day.”

McTighe credits a host of factors for the defeat of the Houston ordinance, which failed despite the endorsements of the White House, Democratic presidential candidate Hillary Rodham Clinton, businesses such as Apple and celebrities including actress Sally Field.

It was added to the ballot in late July, leaving activists just two months to cobble together a campaign, he said. And despite its Democratic bent, Houston is still located in one of the most conservative states in the country.

Much of the state’s that the Republican establishment lined up against the measure, including Gov. Greg Abbott and Lt. Gov. Dan Patrick, as well as some African American Democrats. The reason the measure failed, they said, was simple: People are not comfortable allowing men in women’s bathrooms.

“The win here was huge in the eyes of the country,” said Jared Woodfill, co-chairman of the Campaign for Houston, one of the main groups opposing the ordinance. He predicted that the bathroom issue would be taken up in other communities that oppose anti-discrimination ordinances.

“I think clearly it is a spark that is going to start a revolution,” he said.