PHOENIX -- Arizona's governor vetoed a bill that would have protected people who asset their religious belief in refusing service to gays, ending a proposal that put America's deep polarization over gay rights on stark display.

The bill backed by Republicans in the state's Legislature set off a national debate over religion and discrimination, and opponents called it an open attack on gays.

Brewer's decision Wednesday defused the furor. Companies including Apple Inc. and American Airlines and even national Republicans including Sen. John McCain had urged her to veto the bill, saying it would hurt the state and could alienate businesses looking to expand there.

Loud cheers erupted outside the Capitol building immediately after Brewer made her announcement.

The governor said the bill "could divide Arizona in ways we could not even imagine and no one would ever want." The bill was broadly worded and could result in unintended negative consequences, she added.

The bill would have allowed people to claim their religious beliefs as a defence against claims of discrimination. Democrats said the bill could allow people to break nearly any law and cite religious freedom as a defence.

The governor's office said it had received more than 40,000 calls and emails on the legislation, with most of them urging a veto.

Similar bills are making their way through several state legislatures. Some are intended to protect gay-marriage bans, others to protect individuals or businesses who, for religious reasons, don't want to serve same-sex couples.

In another closely watched case Wednesday, a federal judge declared Texas' ban on gay marriage unconstitutional, but he left it in place until an appeals court can rule on the case. Similar rulings have been made in Utah, Oklahoma and Virginia.

Conservatives are wrestling with how to respond to the growing legality of gay marriage in the U.S.

"This ruling is the poster child of the culture war occurring in America today," said Todd Staples, a candidate for Texas lieutenant governor who drafted the state's constitutional amendment banning gay marriage.

Polls show the legal decisions come amid growing public support for gay marriage in the U.S. At least 17 states, mostly in the Northeast, and the Washington capital district now allow marriage of same-sex couples.

But there has been a backlash among conservatives who say "activist" judges are overturning the will of citizens who have voted to ban same-sex marriage.

"Texans spoke loud and clear by overwhelmingly voting to define marriage as a union between a man and a woman in our Constitution, and it is not the role of the federal government to overturn the will of our citizens," said Texas Gov. Rick Perry.

Arizona's bill thrust the state into the national spotlight last week after both chambers of the state legislature approved it.

Three Republicans who voted for the bill last week changed course and urged Brewer to veto it. They said in a letter to Brewer that while the intent of their vote "was to create a shield for all citizens' religious liberties, the bill has been mischaracterized by its opponents as a sword for religious intolerance."

The Center for Arizona Policy, a powerful social conservative group that backs conservative Christian legislation and is opposed to gay marriage, argues the law is needed to protect against increasingly activist federal courts and simply clarifies existing state law.

"We see a growing hostility toward religion," said Josh Kredit, legal counsel for the group.

Arizona's voters approved a ban on gay marriage as a state constitutional amendment in 2008. A lawsuit challenging the ban is still in its early stages.

Arizona is one of 29 states with such constitutional prohibitions, according to the National Conference of State Legislatures.

------

Associated Press reporter Brady McCombs in Salt Lake City and Jesse Holland in Washington contributed.