A man urges people to vote against the Houston Equal Rights Ordinance outside an early voting center in Houston on Wednesday, Oct. 21, 2015. The contested ordinance is a broad measure that would consolidate existing bans on discrimination tied to race, sex, religion and other categories in employment, housing and public accommodations, and extend such protections to LGBT people. Photo: Pat Sullivan, AP

A man urges people to vote against the Houston Equal Rights Ordinance outside an early voting center in Houston on Wednesday, Oct. 21, 2015. The contested ordinance is a broad measure that would consolidate existing bans on discrimination tied to race, sex, religion and other categories in employment, housing and public accommodations, and extend such protections to LGBT people. Photo: Pat Sullivan, AP

HOUSTON — An ordinance that would have established nondiscrimination protections for gay and transgender people in Houston failed to win approval from voters on Tuesday.

The Houston Equal Rights Ordinance was rejected after a nearly 18-month battle that spawned rallies, legal fights and accusations of both religious intolerance and demonization of the lesbian, gay, bisexual and transgender community.

Supporters of the ordinance had said it would have offered increased protections for gay and transgender people, as well as protections against discrimination based on sex, race, age, religion and other categories.

Opponents of the ordinance, including a coalition of conservative pastors, said it infringed on their religious beliefs regarding homosexuality. But in the months leading up to Tuesday’s vote, opponents focused their campaign on highlighting one part of the ordinance related to the use of public bathrooms by transgender men and women that opponents alleged would open the door for sexual predators to go into women’s restrooms.

Democratic Houston Mayor Annise Parker, who is gay, and other supporters of the ordinance had called this “bathroom ordinance” strategy highly misleading and a scare tactic.

The ordinance was initially approved by the Houston City Council in May 2014 but a lawsuit to have residents vote on the measure eventually made it to the Texas Supreme Court, which in July ordered the city to either repeal the ordinance or put it on the ballot.

Tuesday’s referendum drew attention from around the U.S., with the measure getting high-profile endorsements last week from the White House, high-tech giant Apple and Democratic presidential candidate Hillary Rodham Clinton. The ordinance also had received support from other members of Houston’s religious community.

Campaign for Houston, which fought the ordinance, said opponents included a diverse group of individuals, such as pastors from all denominations and local and state elected officials.

On Monday, Republican Texas Gov. Greg Abbott had tweeted his support for opponents, saying, “HOUSTON: Vote Texas values, not @HillaryClinton values. Vote NO on City of Houston Proposition 1. No men in women’s bathrooms.”

© 2015, Associated Press, All Rights Reserved.

This material may not be published, broadcast, rewritten, or redistributed.