Democratic challenger Jared Golden prevailed Thursday in a Maine congressional contest, defeating a Republican incumbent in the first federal race in the country in which a ranked-choice voting system was used to determine the winner.

After Election Day, Golden, a state representative, narrowly trailed Rep. Bruce Poliquin (R) in a four-way race in which no candidate received 50 percent of the vote.

The result flipped Thursday after the rules of the ranked-choice system were applied. The system allows voters to cast ballots for their candidate but also rank other contenders in order of preference. If no one wins more than 50 percent of the vote outright, those choices are factored in.

At noon Thursday, Maine Secretary of State Matthew Dunlap and his office powered up “instant runoff” software while streaming on Facebook Live to announce the results: Golden won with 50.5 percent of the vote to Poliquin’s 49.5 percent.

The result was the latest Republican-held congressional seat to flip Democratic. Overall, Democrats have won 38 seats that were previously held by Republicans. Democrats have won 230 seats to 198 for the GOP, with seven races undecided.

Poliquin unsuccessfully sought a temporary restraining order from a federal court Tuesday, seeking to stop the state from using the system.

In a victory speech Thursday afternoon, Golden thanked the secretary of state, his opponents and ranked-choice voters.

“Using ranked-choice voting, we’ve determined a clear winner in a more timely manner than Louisiana and other states that hold runoff elections,” Golden said. “And I’m going to go out on a limb here: I’m sure I’m not the only one in the state that’s glad we used an instant-runoff system instead of holding another election. Who in this state wants to see another campaign commercial wedged in between Thanksgiving and Christmas?”

Two independents, Tiffany Bond and Will Hoar, garnered about 8 percent of the vote in Maine’s 2nd District on Election Day. Their voters’ lower preferences were added to the Poliquin and Golden vote totals in a lengthy process of shipping, scanning and certifying ballots in the State House in Augusta.

Ranked-choice voting is a new method that Maine passed by statewide referendum in 2016 and upheld in 2018. It’s often referred to as instant-runoff voting.

Maine’s implementation of the system faced steep opposition from many Republicans in the state. Before the election, Poliquin had refused to say that he would accept the use of ranked-choice tabulation.