BOSTON — The Massachusetts Senate voted Tuesday to repeal a 1913 law used to bar out-of-state gay couples from marrying in the state, a law that critics say was originally aimed at interracial marriages.

The law prohibits couples from obtaining marriage licenses if they can't legally wed in their home states.

The House is expected to vote on the repeal measure later this week. The Senate action came on a voice vote.

After Massachusetts became the first state to allow gay marriages in 2004, then-Gov. Mitt Romney ordered town clerks to enforce the then-little-known 1913 law and deny licenses to out-of-state couples.

Critics, including Democratic Gov. Deval Patrick, the state's first black governor, said the 95-year-old statute carries a racist taint and needs to be repealed.

The law dates to a time when the majority of states still outlawed interracial marriages, and backers of repeal said the law was intended to smooth relations with those states. Massachusetts has allowed interracial marriages since 1843.

Dianne Wilkerson, the state Senate's lone black member, said repeal was long overdue.

"This is one of the most pernicious statutes on our books," said Wilkerson, a Boston Democrat. "In some respects this bill puts the final nail in the coffin of those dark days."

Another factor driving the repeal effort in Massachusetts was the recent embrace of same-sex marriage by California, which has no residency requirement for obtaining a marriage license.

Opponents of gay marriage said there was no evidence the 1913 law has a racist heritage. They said keeping the law in place was key to preventing gay marriage from spreading to other states, many of which have passed laws or amended their constitution to bar same-sex marriage.

"The Massachusetts Senate has no right to infringe on the internal issues of how other states define marriage, but that's exactly what they voted today to do," said Kris Mineau, president of Massachusetts Family Institute.

An analysis by the state Office of Housing and Economic Development found repealing the law would draw thousands of couples to Massachusetts, boosting the economy by $111 million, creating 330 jobs and generating $5 million in taxes and fees over three years.