Democrat Seth Magaziner stunned Republican Allan Fung and his supporters by winning the open seat in Rhode Island’s Second Congressional District, backed by strong performances in Cranston and Warwick and a roughly three-to-one advantage in mail ballots.

“We were behind in every single poll, every single pundit -- every single pundit -- thought we were going to lose,” Magaziner told excited supporters at The Graduate Providence, a downtown hotel, “but you never stopped believing, you never stopped working, and because of you we got this done.”

With 99 of precincts reporting and many mail ballots counted, unofficial results showed Magaziner with 50.3% of the vote, compared with 47% for Fung.

Fung sounded wounded as he gave his concession speech at Twin Oaks, the well-known restaurant in Cranston and the scene for one of his folksy campaign ads. He thanked his supporters and offered his congratulations to Magaziner.

“I never wavered from my commitment to you, to improve Rhode Island and to setting our country on a better path, a more affordable path,” Fung said. “While we didn’t achieve our shared mission tonight, please know that I will continue to work in any capacity I can to make our state better for all of you and for generations to come.”

The outcome marked the third significant political setback for Fung, who lost campaigns for governor in 2014 and 2018.

Asked about his future plans, he told reporters he plans to catch up on his sleep. Fung said he has no regrets about not running for governor instead of pursuing the seat in CD2 and plans in the short term to resume his work at a law firm.

Fung expressed confidence in recent days that he would win the seat being vacated after 22 years by U.S. Rep. Jim Langevin, a Democrat, and GOP allies poured millions in spending into the state in support of Fung’s campaign. Total spending in the race topped $12 million.

Fung maintained a disciplined message in attacking Democrats for the cost of living, the top issue for voters in a series of polls.

Magaziner emphasizing protecting abortion rights and he said Republicans who voted against certifying Joe Biden as president in 2021, including GOP Minority Leader Kevin McCarthy, are a threat to democracy.

Some analysts gave Fung an edge in his hope of becoming the first Republican to win a U.S. House seat in Rhode Island since Ron Machtley won his last term, in the First District, in 1992.

But even in Fung’s expected hometown stronghold of Cranston -- where he served as a generally well-liked mayor from 2009 to 2021 -- the Republican candidate edged Magaziner by less than two points, according to unofficial results.

After narrowly trailing Fung for part of the evening, Magaziner took the lead -- to the delight of Democrats gathered in Providence.

Magaziner said his priorities in Congress will include supporting a transition to affordable green energy “and fight to preserve our democracy for the next generation after that and on and on and on.”

He said he will fight to make it easier for working people to get ahead and “to bring Rhode Island values to Washington.”

Magaziner is approaching the end of his second term as general treasurer. His father, Ira Magaziner, served as an aide in the Clinton White House.

Alex Nunes contributed to this report.

Ian Donnis can be reached at idonnis@ripr.org