Gov. Terry McAuliffe, shown at Mark Twain Middle School in Alexandria in December, vetoed a bill Wednesday that would have prohibited state agencies from punishing religious organizations that discriminate against same-sex couples. (Evelyn Hockstein/For The Washington Post)

Gov. Terry McAuliffe vetoed a Republican-backed bill Wednesday that would have prohibited state agencies from punishing religious organizations that discriminate against same-sex couples.

The veto comes the same week that similar legislation drew attention to Georgia, where Gov. Nathan Deal (R) rejected a “religious freedom” bill, and North Carolina, where Gov. Pat McCrory (R) signed a bill that stops municipalities from passing laws to protect lesbian, gay and transgender people.

McAuliffe (D) vetoed the Virginia bill during a radio show.

“It’s unconstitutional. It is discriminatory,” he said on WTOP’s “Ask the Governor” program. “It demonizes folks. It brings fear and persecution. We can’t tolerate that.”

In North Carolina, businesses are pushing back against its new state law, and McAuliffe said the Virginia bill would have hurt his efforts to grow the economy.

“We need Virginia to be open and welcoming to everyone,” he said.

In a statewide poll released last month by Christopher Newport University, a majority of Virginians said businesses should not be able to refuse service to gays and lesbians based on religious beliefs.

Republicans said the Virginia legislation is needed to protect religious freedom in the face of increasing cultural acceptance of the lesbian, gay, bisexual and transgender community. Democrats say the proposal would give people a license to discriminate and is unconstitutional.

The battle played out this year in Virginia during the recent legislative session.

The bill’s sponsor, Sen. Charles W. Carrico Sr. (R-Grayson), said the measure was a proactive attempt to protect clergy and religiously affiliated schools and would prevent the “persecution” that he said some already face from gay rights supporters.

“It’s just a matter of time, I feel, before someone tries to sue the church,” he said in a phone interview. “I think you see a trend around the country right now to promote homosexual beliefs, and I think you see that trend happening on a wide-scale basis.”

The veto, which was expected, sparked widespread praise from gay rights groups and Democrats.

James Parrish, executive director of Equality Virginia, said the fact that the legislature approved the bill means that more must be done to protect gay rights.

“The majority of Virginians believe in fairness and equality, and it is discouraging to see so many of our legislators unwilling to stand with them for what is right by passing discriminatory legislation,” he said in a statement.

But Victoria Cobb, president of the conservative Family Foundation of Virginia, said the bill would have protected those who disagree with the U.S. Supreme Court, which in a 5-to-4 ruling affirmed same-sex couples’ right to marry in all 50 states.

“Disagreement over the nature and purpose of marriage is not going to disappear simply because the Supreme Court created a mythological right to redefine marriage,” she said in a statement. “It is unfortunate that Governor McAuliffe is so willing to discriminate against people of faith who simply disagree with the secular left’s sexual dogma,” she said.

There are not enough votes in the Republican-controlled General Assembly to override McAuliffe’s veto.

Conservatives in the Virginia House passed another bill earlier in this year’s legislative session that would have allowed discrimination not just against gay married couples but also against transgender people and anyone straight or gay who has sex outside of marriage.

Del. Mark D. Sickles (D-Fairfax), who is gay, gave an emotional floor speech urging his colleagues to consider the sweep of history before casting a vote that could haunt them for the rest of their lives.

Some young Republican lawmakers broke with their party to vote no, reflecting the generational divide on gay rights within the GOP nationally.

That bill, sponsored by Del. C. Todd Gilbert (R-Shenandoah), was amended in the Senate, but instead of agreeing to those changes, the House worked with the Senate to pass compromise legislation based on Carrico’s bill.