A bill that would legalize same-sex marriage in Maryland was approved by the state Senate, which advanced a measure that narrowly cleared the House of Delegates last week.

The final vote by the state Senate ended a yearlong drama in Annapolis over the legislation, and marked the first time an East Coast state south of the Mason-Dixon line has supported gay nuptials.

With the vote, the measure moves to Gov. Martin O’Malley (D), who has said he will sign it.

Maryland would join the District and seven states in allowing same-sex marriages. Supporters have cast the bill as a major advance in equal rights. Opponents have called it a misguided attempt to redefine the institution of marriage.

Despite one of the largest Democratic majorities in any state legislature, backers of gay marriage in Maryland had to overcome fierce opposition from blocks of African American lawmakers and those with strong Catholic and evangelical views to cobble together coalitions big enough to pass both chambers.