ANNAPOLIS, Md. — The Maryland Senate voted 27 to 20 on Wednesday to repeal the state’s death penalty after four days of heated and emotional debate, putting Governor Martin O’Malley on the brink of a long-sought legislative victory.

Supporters of the legislation argued that capital punishment is not an effective deterrent, is costly, and creates the risk of executing innocent people.

‘‘We have a broken system here in Maryland,’’ said Senator Victor Ramirez, a Prince George’s County Democrat, who cited statistics showing capital punishment has been more likely to be imposed in Maryland in cases involving a black assailant and white victim.

Advertisement

Opponents countered that the death penalty can be an important law-enforcement tool and should be kept on the books for heinous cases, several of which were recounted in graphic detail on the Senate floor.

‘‘That ultimate punishment still needs to be available,’’ Senator Christopher Shank, a Washington County Republican, said. ‘‘We are talking about the worst of the worst. We are talking about crimes against humanity.’’

The bill moves next to the House of Delegates, and repeal advocates say they are confident they have enough votes for its passage. The Senate had long been viewed as the tallest hurdle for the legislation.

O’Malley’s repeal bill was introduced this session with 67 cosponsors in the House, leaving supporters just four delegates to sway to get a majority. Delegate Samuel Rosenberg, a Baltimore Democrat who
championed the legislation, said he is confident his side has the votes to prevail in coming weeks.

Maryland voters could have the final say on the issue, however. If the bill passes the House, opponents have vowed to make use of a provision in the state Constitution that allows citizens to petition recently passed laws to the ballot, as happened with same-sex marriage last year. The outcome of a death penalty referendum would be far from certain.

Advertisement

A Washington Post poll released last week showed that a majority of Marylanders want to keep the death penalty on the books despite widespread skepticism across the state about whether capital punishment is a deterrent to murder or is applied fairly.

O’Malley’s bill would replace death sentences with life in prison without the possibility of parole. It would not affect the five inmates currently on death row in Maryland, leaving it to the governor to determine whether to commute their sentences.

O’Malley has been an outspoken advocate for repeal since taking office in 2007. He sponsored a bill to repeal the death penalty in 2009, but the measure was rejected by the Senate, which chose instead to tighten evidentiary standards in capital cases.

Since then, several new members have been elected, and a couple of senators have changed their positions, creating a majority of supporters for the first time.

‘‘A lot of different things have come into play here, including the governor making a very strong push,’’ said Senate President Thomas V. Mike Miller, a Calvert Democrat who supports the death penalty.