Legislators in nearby New Hampshire were also poised to send a gay marriage bill to their governor, who hasn't indicated whether he'll sign it.
The Maine Senate voted 21-13, with one absent, for a bill that authorizes marriage between any two people rather than between one man and one woman, as state law currently allows. The House had passed the bill Tuesday.
Democratic Gov. John Baldacci, who hadn't previously indicated how he would handle the bill, signed it shortly afterward. In the past, he said he opposed gay marriage but supported civil unions, which provide many benefits of marriage.
Debate was brief. Senate President Elizabeth Mitchell turned the gavel over to an openly gay member, fellow Democrat Sen. Lawrence Bliss, to preside over the final vote.
Republican Sen. Debra Plowman argued that the bill was being passed "at the expense of the people of faith."
But Senate Majority Leader Philip Bartlett II said the bill does not compel religious institutions to recognize gay marriage.
"We respect religious liberties. ... This is long overdue," said Bartlett, a Democrat.
Maine is now the fourth state in the northeastern New England region to allow same-sex marriages. Connecticut enacted a bill after being ordered to allow gay marriages by the courts, and Vermont passed a bill over the governor's veto. Same-sex marriage is also legal in the Midwestern state of Iowa.
The state House in New Hampshire, also in New England, was also expected to vote on a bill Wednesday and send it to Gov. John Lynch, a Democrat.
If New Hampshire allows gay marriage, Rhode Island would the New England holdout. A bill to legalize same-sex marriage in Rhode Island has been introduced but is not expected to pass this year.
Same-sex marriage was briefly legal in California before voters banned it last year.