Maryland Gov. Martin O'Malley speaks at a rally in support of repealing the state's death penalty in Annapolis on Jan. 15. (Patrick Semansky/Associated Press)

The Maryland Senate voted to repeal the death penalty Wednesday after four days of emotional debate, moving the state closer to becoming the sixth in as many years to abolish executions.

The 27 to 20 vote was widely seen as a key step in ending capital punishment in Maryland, which has not executed a death-row prisoner since 2005. The legislation now goes before the House of Delegates, where a vote could come as early as next week.

The House is expected to approve the measure, handing Gov. Martin O’Malley a long-sought legislative victory at a time when he is weighing a run for national office in 2016.

“It’s time to end this ineffective and expensive practice and put our efforts behind crime fighting strategies that work,” O’Malley (D) said in a statement.

Shari Silberstein, executive ­director of Equal Justice USA, a group that is working to end the death penalty, said that Maryland’s action is part of a national trend and that she envisions another half-dozen states adopting the policy in the next several years.

“Just a few years ago, you wouldn’t have had a governor with national ambitions making this a banner issue,” Silberstein said. “It’s no longer the ‘third rail’ of politics. Voters don’t punish people at the polls for being anti-death penalty.”

Wednesday’s debate underscored the internal struggles for many senators.

Sen. Victor R. Ramirez (D-Prince George’s), a supporter of the bill, cited statistics showing that Maryland has been more likely to impose the death penalty in cases with black assailants and white victims.

“We have a broken system here in Maryland,” he said. “If we can’t fix it, we need to get rid of it.”

Repeal 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 during the debate.

“That ultimate punishment still needs to be available,” Sen. Christopher B. Shank (R-Washington) argued to colleagues. “We are talking about crimes against humanity.”

While the death penalty remains on the books in 33 states, many are using it more sparingly than in the past. Last year, 77 people were sentenced to death nationally, the second-lowest number since capital punishment was reinstated in 1976, according to the Death Penalty Information Center.

Del. Samuel I. Rosenberg (D-Baltimore), a champion of the repeal legislation in Maryland, said he is confident supporters have the votes to prevail in the House. O’Malley’s bill was introduced in January with 67 House co-sponsors, or four delegates shy of a majority. The bill also has the backing of House Speaker Michael E. Busch (D-Anne Arundel).

Maryland voters, however, could have the final say on the issue. If the measure passes, opponents have vowed to make use of a provision in the state’s constitution that allows people 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.

A Washington Post poll released last week showed that a majority of Marylanders want to keep the death penalty despite statewide skepticism as to whether capital punishment is a deterrent to murder or is applied fairly.

The bill would replace death sentences with life terms in prison without the possibility of parole. It would not affect the five inmates now on death row, leaving it to the governor to determine whether to commute their sentences.

O’Malley has advocated for repeal of capital punishment since taking office in 2007. Prior to this year, he last sponsored a bill for that purpose in 2009. That measure was rejected by the Senate, with members choosing instead to tighten evidentiary standards in capital cases.

Since then, several new senators have been elected, and a couple of members have changed their positions, creating a majority of Senate supporters for the first time. The NAACP and the Catholic Church have made repeal of Maryland’s death penalty a priority this year as well.

“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 Jr. (D-Calvert), a death penalty supporter.

Several senators on both sides said they remain conflicted.

“I’m jealous of all of you who have these firm beliefs on this, because I don’t,” said Sen. Robert A. Zirkin (D-Baltimore County), who voted for repeal. Zirkin said he had no moral qualms with seeing “horrible monsters” put to death, but he said one nagging thought pushed him to the supporters’ column.

“We could execute an innocent person, and that weighs on my conscience too heavily not to cast a green vote,” he said.

Sen. Jamie B. Raskin (D-Montgomery), who shepherded the bill in the Senate, also credited family members of murder victims who lobbied lawmakers to oppose capital punishment. They have argued that the death penalty does not bring closure.

During the Senate debate, both sides sought to bolster their arguments with some of Maryland’s most prominent murder cases.

Opponents of the bill recounted the killing of Sarah Foxwell, an 11-year-old who was kidnapped, sexually assaulted and slain on the Eastern Shore in 2009.

Her killer “poured gasoline in her mouth, and he burned the body,” Sen. Richard F. Colburn (R-Dorchester) said as he called on his colleagues to “kill this bill.”

Supporters countered with repeated references to Kirk Bloodsworth, a former death-row inmate who was exonerated by DNA evidence and released from prison in 1993. Bloodsworth, a former Marine convicted of raping and murdering a 9-year-old girl in Baltimore County in 1984, watched much of the debate from the Senate gallery.

The state has had an effective moratorium on capital punishment since December 2006, the month before O’Malley took office, when Maryland’s highest court ruled that regulations on lethal injection had not been properly adopted.

The O’Malley administration has yet to implement new regulations, and the shortage of a drug prescribed in Maryland for executions could complicate efforts of any future governor to resume executions.

Some opponents of the repeal criticized O’Malley for failing to move forward during the past several years. “It’s hard to say something doesn’t work if you don’t use it,” Colburn argued.

Two Republicans joined 25 Democrats in the Senate to vote for the repeal Wednesday. The measure was opposed by 10 Republicans and 10 Democrats.