The 33-27 vote by the House sends the legislation to Republican Gov. Jan Brewer and puts Arizona back at the forefront of a polarizing piece of legislation four years after the state enacted an immigration crackdown that caused a national furor.
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 passed.
Republicans stressed that the bill is about protecting religious freedom and not discrimination. They frequently cited the case of a New Mexico photographer who was sued after refusing to take wedding pictures of a gay couple and said Arizona needs a law to protect people in the state from heavy-handed actions by courts and law enforcement.
The legislation prompted a heated debate on the floor of the House, touching on issues such as the religious freedom, constitutional protections and civil rights.
Opponents raised scenarios in which gay people in Arizona could be denied service at a restaurant or refused medical treatment if a business owner thought homosexuality was not in accordance with his religion. One lawmaker held up a sign that read "NO GAYS ALLOWED" in arguing what could happen if the law took effect, drawing a rebuke for violating House rules.
The bill is backed by the Center for Arizona Policy, a social conservative group that opposes abortion and gay marriage. The group says the proposal 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.
All but three Republicans in the House backed the bill Thursday evening. The Senate passed the bill a day earlier on a straight party-line vote of 17-13.
Brewer doesn't comment on pending legislation, but she vetoed a similar measure last year. That action, however, came during an unrelated political standoff, and it's not clear whether she would support or reject this plan.
The legislation comes also as an increasing number of conservative states grapple with ways to counter the increasing legality of gay marriage.
Arizona's voters approved a ban on same-sex marriage as a state constitutional amendment in 2008. It's one of 29 states with such prohibitions, according to the National Conference of State Legislatures. Federal judges have recently struck down bans in Utah, Oklahoma and Virginia, but those decisions are under appeal.
Republican Sen. Steve Yarbrough called his proposal a First Amendment issue during the 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 say it is an outright attack on the rights of gays and lesbians.
"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. 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 a provision from the bill in hopes Brewer will embrace the new version.
Civil liberties and secular groups countered that Yarbrough and the Center for Arizona Policy had sought to minimize concerns that last year's bill had far-reaching and hidden implications. During the Senate debate Wednesday, Democrats said the bill could allow people to break nearly any law and cite religious freedom as a defense.
Yarbrough called those worries "unrealistic and unsupported hypotheticals" and said criminal laws will continue to be prosecuted by the courts.
Rep. Chad Campbell of Phoenix, the Democratic minority leader, said during debate that gays and lesbians across the country would get the message that they're not welcome in Arizona.
"We're telling them, 'We don't like you. We don't want you here. We're not going to protect you," he said.
Senate President Andy Biggs, R-Gilbert, said the Democrats' rhetoric was misplaced.
"Sometimes people's rhetoric tends to inflame instead of explain," Biggs said. "And I would suggest if there is going to be a backlash because of 1062 ... it will because of the intemperate and inaccurate rhetoric."