The measure now moves to the House of Representatives for consideration next week, and then back to the Senate for a third, and perhaps final, vote.
In initial voting, the Senate voted 20-15 to give its preliminary approval. Next, an amendment to require a statewide referendum on the matter was rejected, 22-13. Then the Senate registered its support for the original measure again, this time by 21-14.
On Wednesday, the Senate voted 13-11 in favor of the bill, which differs from the House-approved version in that it distinguishes between civil and religious marriage. It allows each religion to decide whether to acknowledge same-sex marriage but extends the option of civil marriage to any two individuals, said state Senate spokeswoman Anne Saunders.
The House, which passed the earlier version last month by a margin of seven votes, 186-179, must approve the changed version before it can be sent to Gov. John Lynch, a Democrat who has questioned the need for the bill.
After the Senate vote, Lynch released a statement saying he believes that "the fundamental issue is about providing the same rights and protections to same-sex couples as are available to heterosexual couples. This was accomplished through the passage of the civil unions law two years ago."
Lynch signed the state's civil unions law in May 2007.