The New Hampshire House voted Thursday to legalize same-sex marriage, narrowly approving a bill that faces an uncertain future in the State Senate and, should it pass there, most likely a veto by Gov. John Lynch.

Only hours after the measure had failed by one vote, a handful of legislators reconsidered, allowing it to clear the Democratic-controlled House by 186 to 179.

The vote followed by a day an announcement by Gov. Jim Douglas of neighboring Vermont that he would veto a bill legalizing same-sex marriage if it reached his desk. The Vermont Senate approved the bill overwhelmingly last Friday, and the House is hearing testimony on it this week. Vermont was the first state to legalize civil unions of same-sex couples, in 2000, but same-sex marriage is now legal only in Massachusetts and Connecticut.