CONCORD, N.H.—New Hampshire lawmakers on Wednesday rejected a bill that would have made their state legislature the first one to repeal a gay marriage law, handing gay-rights supporters a key victory in the Northeast, where same-sex marriage is prevalent.

The state House voted 211-116 to kill the measure, ending a push by its new Republican majority to rescind New Hampshire's 2-year-old gay marriage law. Nevertheless, both sides are pledging to continue fighting into the fall elections.

Repeal opponents hoped to solidify what they argue is public support for gay marriage, while supporters hoped to reverse the law in a region of the country where gay-rights groups have strength.

"Today is a banner day for the freedom to marry," said Craig Stowell, co-chairman of Standing up For New Hampshire Families. Stowell said the House, where Republicans hold a 189-seat advantage, was supposed to give conservatives their best shot at repeal. "They blew it. This was supposed to be the most favorable legislative climate for repeal and they couldn't even get a majority."

The Republican-backed bill called for repealing gay marriage in March 2013 and replacing it with a civil unions law that had been in place in 2008 and 2009. Gay marriages occurring before the repeal took effect would have remained valid, but future gay unions would have been civil unions. The bill also would have allowed voters to weigh in on the issue through a nonbinding November ballot question.

Tom Czapieo, 63, of Keene, watched the House debate from the gallery with his partner, Mike Bellrose, 61. Czapieo said he was surprised and thrilled by the vote, even though he and Bellerose have no immediate plans to marry.

"I was born this way. I should have the right to marry who I want," he said.

Bellrose noted that the House session began with the Pledge of allegiance, and quoted the ending passage: "with liberty and justice for all."

"This certainly is a big step toward that," Bellerose said.

Eleanor Vander Haegen, 71, of Keene, married her partner of 22 years in January 2010.

"It's such a significant recognition of our human rights," she said of the vote.

If the House passed the repeal measure following its two hours of debate, it would have gone to the Senate; both houses are controlled by Republicans. Democratic Gov. John Lynch had promised to veto the bill if it had reached his desk.