“To achieve further real progress,” he said in a statement, “the federal government would need to take action to recognize New Hampshire civil unions.”

The Defense of Marriage Act, passed by Congress in 1996, prohibits the federal government from recognizing same-sex marriage. It denies federal benefits, like Social Security survivors’ payments, to spouses in such marriages.

Brian Brown, executive director of the National Organization for Marriage, which was established to fight same-sex marriage around the country, said the group would intensively lobby Mr. Lynch to veto the bill.

“This vote is in no way representative of what folks in New Hampshire want,” Mr. Brown said, adding that the Senate leadership had used “arm-twisting” to change the votes of a few crucial Democrats. “If the governor is going to stand by his words,” he added, “he will veto this bill.”

To some extent, the support for same-sex marriage reflects a sea change in New Hampshire politics since 2006, when Democrats gained control of the legislature for the first time in over a century. While staunchly conservative on fiscal matters, New Hampshire has been less so on social issues, partly because its residents’ famous libertarian streak resists government intrusion in personal matters.

But last-minute politicking also played a role in the Senate’s vote. Last week the Senate Judiciary Committee voted 3 to 2 against the marriage measure, and the committee’s chairwoman, Senator Deborah Reynolds, a Democrat, said afterward that New Hampshire was simply not ready for same-sex marriage.

Newsletter Sign Up Continue reading the main story Please verify you're not a robot by clicking the box. Invalid email address. Please re-enter. You must select a newsletter to subscribe to. Sign Up You will receive emails containing news content , updates and promotions from The New York Times. You may opt-out at any time. You agree to receive occasional updates and special offers for The New York Times's products and services. Thank you for subscribing. An error has occurred. Please try again later. View all New York Times newsletters.

Ms. Reynolds, the only Democrat who opposed the bill in committee, emphasized that civil unions were still new in New Hampshire and that Vermont, whose legislature approved same-sex marriage on April 7, had done so only after living with civil unions for nine years.

But on Wednesday, Ms. Reynolds, who represents a fairly conservative region, said the new language made the bill acceptable. She described it as a compromise that was “respectful to both sides of the debate and meets our shared goals of equality under the state laws for all of the people of New Hampshire.”

Advertisement Continue reading the main story

Gov. Jim Douglas of Vermont, a Republican, vetoed that state’s same-sex marriage bill, but the Democratic-controlled legislature overrode his veto, making Vermont the first state to adopt same-sex marriage legislatively instead of through the courts. Days earlier, the Iowa Supreme Court found a state law banning same-sex marriage to be a violation of the State Constitution.

In New Hampshire, more than 650 same-sex unions have been registered since they became legal in January 2008.

Same-sex marriage was among several contentious bills that the Senate took up Wednesday, all passed by the House in recent weeks. One, a measure to allow people with certain illnesses to possess marijuana for medical purposes, passed in a vote of 14 to 10. But the Senate voted unanimously against a bill that would guarantee transgender people protection from discrimination in housing and employment. It also put off action on a bill to repeal the death penalty.

Democrats hold a 14-to-10 majority in the Senate, but it is generally more centrist and cautious than the House, where Democrats hold a 223-to-175 majority.

Opponents of same-sex marriage appeared better organized here than in Vermont. Cornerstone Research Institute waged an intense phone campaign with help from the National Organization for Marriage, but the New Hampshire Freedom to Marry Coalition and other gay-rights groups also lobbied fiercely.

Mo Baxley, the coalition’s executive director, described the Senate bill as a fair compromise.

“It is in keeping with New Hampshire’s live-free-or-die tradition to stand up for individual liberties and against discrimination of any kind,” Ms. Baxley said.

“I have to say,” she added, “America is at a turning point.”