Del. Mark D. Sickles (D-Fairfax), seated right, gets a standing ovation after an emotional speech on a bill relating to religious objections to same-sex marriage at the Capitol in Richmond on Feb. 16. (Steve Helber/AP)

The Virginia House passed a bill Tuesday that would prohibit the government from punishing people and businesses who discriminate against same-sex couples, transgender individuals and those who have sex outside marriage.

Supporters say the Government Nondiscrimination Act is needed to protect what they call religious freedom in the face of shifting cultural attitudes toward gay rights and the legalization of gay marriage. Opponents say it’s a “license to discriminate,” with broad-reaching consequences.

The bill passed the Republican-controlled chamber 56 to 41, with seven Republican members voting “no,” two not voting and one absent. Although the vote is a win for the socially conservative wing of the party, the fact that some Republicans voted against it reflects a divide within the Republican Party in Virginia and the nation.

Before the vote, Del. Mark D. Sickles (D-Fairfax), who is openly gay, gave an emotional floor speech urging his colleagues to consider the sweep of history before they cast a vote that will stay with them for the rest of their lives.

“You’ll have to excuse me for taking this bill a little personally,” he said.

Gov. Terry McAuliffe (D) has said he would veto the measure if it passes the Senate and reaches his desk. But, Sickles said, “Your kids will be looking back at what you do today and how you vote on this bill.”

He went on to read from the program of Equality Virginia’s annual dinner, noting prominent businesses and political donors that support gay rights, including utility giant Dominion, whose ad trumpeted the “power of diversity,” and Lutheran Family Services.

He received a standing ovation from House Democrats.

The bill’s sponsor, Del. C. Todd Gilbert (R-Shenandoah), defended the bill, which he said would provide reasonable accommodation for deeply held religious beliefs.

“We find ourselves constantly under attack by the shifting cultural winds . . . that blow against us,” Gilbert said.

Gay rights activists are not satisfied with equality, he said, “and they will not be satisfied until people of faith are driven out of this discourse. They want us driven out.”

At Gilbert’s urging, some of his colleagues clapped and stood for him, as well.

Under the bill, an individual, corporation, partnership, association, trust, society or any other legal or commercial entity can cite religious belief in defense of its opposition to gay couples, transgender people or unmarried couples without fear of losing tax benefits, grants, contracts, loans, scholarships, certification, accreditation or jobs. There are exceptions for hospitals making decisions about visitation or emergency medical treatment.