Discuss as:

Maryland lawmakers pass bill to allow gay marriage

State senators approved a gay marriage bill 25-22 Thursday, moving Maryland closer to becoming the eighth state in the U.S. to legalize same-sex marriages.

Gay marriage opponents in the Senate unsuccessfully attempted to attach amendments to the House bill, which could have effectively killed it, WBALTV reported.

The House of Delegates approved the bill by a narrow 72-67 vote last week, WBAL reported.

Gov. Martin O’Malley worked closely with House Democratic leaders to secure the votes needed for passage, The Baltimore Sun reported.

O’Malley released a statement Thursday, thanking Senate President Mike Miller for his efforts in getting the bill passed. “All children deserve the opportunity to live in a loving, caring committed, and stable home, protected equally by the law,” the statement said.

Opponents have vowed to bring the measure to referendum in November. They will need to gather at least 55,726 valid signatures of Maryland voters to put it on the ballot and can begin collecting names now that the bill has passed both chambers, the Associated Press reports.

Recent polls have shown that Marylanders are evenly split on the issue, the Sun reported.

Last week, the Washington governor signed a gay marriage bill into law. That law could also be challenged in a November referendum if opponents gather enough signatures.

Also last week, the New Jersey legislature approved a same-sex marriage bill, but Gov. Chris Christie vetoed the measure.

More content from msnbc.com and NBC News