Gov. Jan Brewer on Wednesday vetoed a Republican bill that set off a national debate over gay rights, religion and discrimination and subjected Arizona to blistering criticism from major corporations and political leaders of both parties.

Brewer’s decision was the latest move in a national debate over gay rights and religious freedom.

The bill backed by Republicans in the Legislature was designed to give added protection from lawsuits to people who assert their religious beliefs in refusing service to gays. But opponents called it an open attack on gays that invited discrimination.

The bill thrust Arizona into the national spotlight last week after both chambers of the state legislature approved it. As the days passed, more and more groups, politicians and average citizens weighed in against Senate Bill 1062. Many took to social media to criticize the bill, calling it an attack on gay and lesbian rights.

Prominent Phoenix business groups said it would be another black eye for the state that saw a national backlash over its 2010 immigration-crackdown law, SB1070, and warned that businesses looking to expand into the state may not do so if bill became law.

Companies such as Apple Inc. and American Airlines and politicians including Sen. John McCain, R-Ariz., and former Republican presidential nominee Mitt Romney were among those who urged Brewer to veto the legislation.

Three Republicans who had voted for the bill last week also urged Brewer to reject 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.”

SB 1062 allows people to claim their religious beliefs as a defense against charges of discrimination. Backers cite a New Mexico Supreme Court decision that allowed a gay couple to sue a photographer who refused to document their wedding, even though the law that allowed that suit doesn’t exist in Arizona.

Republican state Sen. Steve Yarbrough called his proposal a First Amendment issue during a Senate debate.

“This bill is not about allowing discrimination,” Yarbrough said. “This bill is about preventing discrimination against people who are clearly living out their faith.”

Democrats said it was a veiled attempt to legally discriminate against gay people and could allow people to break nearly any law and cite religious freedom as a defense.

“The heart of this bill would allow for discrimination versus gays and lesbians,” said Sen. Steve Gallardo, D-Phoenix. “You can’t argue the fact that bill will invite discrimination. That’s the point of this bill. It is.”

The bill is similar to a proposal last year brought by Yarbrough but vetoed by Brewer, a Republican. That legislation also would have allowed people or religious groups to sue if they believed they might be subject to a government regulation that infringed on their religious rights. Yarbrough stripped that provision from the bill in the hopes Brewer will embrace the new version.

Civil-liberties and secular groups countered that Yarbrough and the Center for Arizona Policy, a powerful social conservative group that is opposed to gay marriage, had sought to minimize concerns that last year’s bill had far-reaching and hidden implications.

Yarbrough called those worries “unrealistic and unsupported hypotheticals” and said criminal laws will continue to be prosecuted by the courts.

The Center for Arizona Policy 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.

Similar religious-protection legislation has been introduced in Ohio, Mississippi, Idaho, South Dakota, Tennessee and Oklahoma, but Arizona’s plan is the only one that has been passed by a state legislature. The efforts are stalled in Idaho, Ohio and Kansas.