PROVIDENCE, R.I. — The Rhode Island Senate on Wednesday approved a bill that would allow same-sex couples to enter into civil unions, a measure that Gov. Lincoln Chafee’s office says he intends to sign into law.

State senators voted 21-16 to endorse the bill, about two hours after it was voted out of committee. The legislation, which already has passed the state House, allows gay couples to enter into civil unions that offer the same rights and benefits given to married couples under Rhode Island law.

It is now headed to Chafee’s desk for his signature. Ahead of the vote, the independent governor called the legislation an “incremental step” toward allowing gay marriage, which he supports.

Earlier this month, New York became the sixth state to allow gay marriage, joining Iowa, Massachusetts, Vermont, New Hampshire and Connecticut, as well as the District of Columbia. Several other states offer civil unions or domestic partnerships instead. Lawmakers modeled the Rhode Island bill on civil union laws enacted this year in Illinois, Delaware and Hawaii.

Senate President Teresa Paiva Weed, D-Newport, a notable opponent of gay marriage, spoke in favor of civil unions ahead of the vote, calling it a “historic day” for Rhode Island.

On the floor, debate of the contentious bill ahead of the vote remained civil, although one senator who voiced his religious opposition to the bill drew audible hisses.

Several gay marriage advocacy groups have urged Chafee to veto the bill because of what they call overly broad exemptions that would allow religious institutions to ignore rights given through civil unions. The measure would, for instance, let religious hospitals refuse a civil union spouse the right to make emergency medical decisions.

Those groups and some state senators on the floor Wednesday have also said civil unions don’t go nearly far enough and treat gay couples as second-class citizens.

While it’s correct “to say this bill is historic and consequential,” said Sen. Rhoda Perry, D-Providence, it’s also correct “to say this bill is not fair, nor equitable.”

Some other senators compared the bill to the “separate but equal” doctrine that justified racial segregation.

Meanwhile, groups opposed to gay marriage, which supported the religious exemption but said it didn’t go far enough, called civil unions a dangerous stepping stone to full gay marriage rights. Capitol police hauled off one activist opposed to the bill in handcuffs after he held up a sign condemning it during floor debate on the state budget and shouted slogans from the gallery ahead of t he vote on civil unions.

“This is a disappointing and dangerous day for marriage in Rhode Island,” said Chris Plante, executive director of the National Organization for Marriage-Rhode Island. The bill’s passage “presents a clear threat to the definition of marriage and the religious liberties of tens of thousands of Rhode Islanders.”

Like some senators, Plante said the matter was best decided by a statewide referendum.

The civil unions bill was introduced as a compromise after House Speaker Gordon Fox, D-Providence, said gay marriage legislation would not pass the General Assembly this year. Fox, who is openly gay, supports gay marriage but said it couldn’t overcome opposition, particularly in the Senate.

The switch was a blow to the efforts of groups like Marriage Equality Rhode Island, which was among those calling on Chafee to veto the bill if it included the religious exemptions amendment.

Ray Sullivan, MERI’s campaign director, called the exemption a “black eye on the state of Rhode Island.”

Many senators heralded the bill as an example of tough legislative “compromise,” a word Sullivan bristled at, asking how many straight senators would compromise their own rights.

“I’m not sure they’d be so quick to use the word compromise when it affects them,” he said. “You compromise on tax policy. You compromise on labor negotiations. You don’t compromise on people’s fundamental human rights.”

Still, other supporters of gay marriage called the bill a step in the right direction.

“We have made great progress in our goal of providing increased rights, benefits and protections for gay and lesbian couples,” said Rep. Peter J. Petrarca, D-Lincoln, after the vote. Petrarca sponsored the bill in the House. “This bill is a step forward to ensuring equality and improving their quality of life.”

Paiva Weed, the Senate president, said after the committee vote that, if the bill passed the Senate, she didn’t expect a push next year for a gay marriage bill.

Sullivan begged to differ.

“We’ll be back tomorrow and the next day and however long it takes for Rhode Islanders to be treated equally under the law,” he said.