PROVIDENCE — As more than 1,000 ecstatic supporters looked on, Governor Lincoln Chafee on Thursday signed legislation making Rhode Island the 10th state in the nation to permit gays and lesbians to wed, and establishing gay marriage as the law of the land throughout all of New England.

“Today, we are making history,” Chafee told the crowd. “We are living up to the ideals of our founders.”

He also cast the bill in economic terms, saying vital new businesses want to come to places that reflect their values, “and now, Rhode Island does.”

Even as gay couples won the right to marry in other New England states over the past decade, the political and religious opposition in Rhode Island remained formidable, with bills repeatedly failing in the Legislature.

“Democracy, though it may take a long time, does work,” said House Speaker Gordon Fox, who is gay.

Whoops and energetic applause roared through the building’s marble halls when state representatives gave final approval to the measure Thursday afternoon, in a vote to reconcile two slightly different versions of the bill. Supporters hugged on the floor of the House chamber and wiped back tears. A rainbow flag hung from the gallery. About 40 gay marriage proponents sang “My Country, ’Tis of Thee.”

The Roman Catholic Church fought fiercely against the measure in a state that is liberal but also heavily Catholic. In defeat, Bishop Thomas J. Tobin, the outspoken head of the Diocese of Providence, issued a letter saying he is “profoundly disappointed that Rhode Island has approved legislation that seeks to legitimize ‘same-sex marriage,’ ” which he called “objectively sinful.”

“Catholics should examine their consciences very carefully before deciding whether or not to endorse same-sex relationships or attend same-sex ceremonies, realizing that to do so might harm their relationship with God and cause significant scandal to others,” Tobin said.

As other New England states began to legalize gay marriage, beginning with Massachusetts in 2004, similar bills in Rhode Island generated little momentum. Tobin, appointed in 2005 to lead the diocese, emerged as the leading public spokesman against gay marriage, while proponents lacked a figure of the bishop’s statewide stature. Political realists also understood there was little chance to approve gay marriage during the tenure of Governor Donald Carcieri, a socially conservative Republican who held office from 2003 to 2011.

The November 2010 election of Chafee, a former moderate Republican US senator who left the party to become an independent, proved a major turning point. Upon taking office on Jan. 4, 2011, Chafee immediately signaled a new political climate, calling in his inaugural address for the legalization of same-sex marriage.

“When marriage equality is the law in Rhode Island, we honor our forefathers who risked their lives and fortune in the pursuit of human equality,” the new governor said.

Later that year, as gay marriage legislation foundered in the Rhode Island General Assembly amid ferocious debate, lawmakers approved a compromise civil unions bill, which accomplished the remarkable political feat of infuriating just about everyone on both sides of the issue. Gay marriage proponents thought the bill was a half-measure and a cop out; opponents thought civil unions were too close to marriage.

In the interim, gay marriage proponents gathered significant national momentum. President Obama became the first US president to back gay marriage, suffering no apparent political backlash in his reelection campaign. And public opinion polls continued to show growing support for gay marriage, including overwhelming support among young voters. In Rhode Island, gay marriage supporters improved their political efforts, hiring veteran operatives to manage a campaign to pressure lawmakers.

“The campaign was one of the largest in Rhode Island — knocking on doors and engaging legislators,” said state Representative Frank Ferri, a Democrat from Warwick and a leading proponent of the legislation. “Sometimes it’s about timing; it just came together this time.”

In January, the Rhode Island House overwhelmingly approved a same-sex marriage bill.

The state Senate provided drama and an emotional debate in April, though in the end the 26-to-12 vote was emphatic. The chamber’s five Republicans all supported the measure, apparently becoming the first legislative caucus in the United States to unanimously support gay marriage, according to Senate minority leader Dennis L. Algiere, a Republican from Westerly.

“The caucus individually and collectively strongly believes in the principles of fairness and equality,” Algiere said Thursday. “We think those are the principles of the Rhode Island [Republican] party.”

The results of Thursday’s House vote were a foregone conclusion, but several members rose to make their final points.

“I’m rising in support of my brother, who had to hide from our [family] and go to Mexico, because nobody accepted him the way that he is,” said an emotional Representative Grace Diaz. “I rise in support of myself because I have the courage to talk with my friends in the church and tell them that this bill is all about love.”

An opponent, Representative James N. McLaughlin, alluded to his religious faith. “I love every one of you as brothers and sisters in Christ,” he said. “I’m a Catholic, and so are a lot of you people. . . . I want to say that I’m going to follow my Lord and Savior, my beliefs, and I hope you respect that. I have no bigotry in my heart.”

Another opponent, Representative Arthur J. Corvese, said the bill alters a “millennium-old definition of traditional marriage.”

“There is no man-made law that can ever replace, supplant, suppress, or subjugate the natural law,” Corvese said.

State Representative Art Handy, a Cranston Democrat and a leading proponent of the legislation, said in a Globe interview this year’s gay marriage debate seemed less contentious than previous ones.

“Time has been marching on in terms of public opinion,” said Handy. “There are so many young people who do not understand how in the world this is an issue that people are unhappy about. It just doesn’t make any sense to them.” Working on the gay marriage issue “helped me appreciate my own marriage and my relationship with my wife even more,” said Handy. “I’m hoping more people will feel that.”

On Aug. 1, the date the Rhode Island bill takes effect, coincidentally, Representative Ferri and his spouse, Tony Caparco, will mark 32 years together, Ferri said. They married in Canada in 2006.

“We would like to get married in Rhode Island and we just have to make sure that we can,” said Ferri, who wants to be sure they may legally exchange vows a second time, and in a new jurisdiction.

“If we do get married, we’ll ask the speaker to marry us,” he said in a Globe interview. “It’s a great day today. It’s surreal for us right now.”

The floor session was marked by a moment of levity when Representative Deborah A. Fellela said she came to favor the bill after finding herself wondering why she has the privilege to marry but gays and lesbians do not.

“Even though in my situation, maybe right now it isn’t a privilege,” said Fellela, whose husband was arrested
twice in the last two months on credit card fraud charges.