Democrat Conor Lamb has claimed victory in an election in a Republican stronghold in Pennsylvania which is seen as a key indicator of Donald Trump’s popularity.
Republican Rick Saccone was just a few hundred votes behind and refused to admit defeat in the special election in the 18th Congressional District.
It was called when longtime Republican congressman Tim Murphy, who espoused strong anti-abortion views, resigned last autumn amid revelations of an extramarital affair in which he urged his mistress to get a termination.
The contest has drawn national attention as a bellwether for the midterm elections in November when the Republican Party’s House and Senate majorities are at risk.
Earlier, Mr Saccone told his own supporters: “It’s not over yet, we’re going to fight all the way, all the way to the end, we’ll never give up.”
Regardless of the outcome — and a recount was possible — Mr Lamb’s showing in a district Mr Trump won by 20 points in the presidential race was sure to stoke anxiety among Republicans nationwide and renewed enthusiasm among Democrats.
On Wednesday morning, Mr Lamb’s lead stood at 641 votes out of more than 224,000 cast, according to unofficial results.
Election officials said there are about 200 absentee votes and an unknown number of provisional ballots still to be counted.
The four counties in the western Pennsylvania district have seven days to count provisional ballots.
In a race this close, either candidate’s supporters can ask for a recount. However there are tough requirements, including needing three voters in the same precinct who can attest that error or fraud was committed.
The ultimate winner will face re-election in just eight months, and the congressional district as currently shaped will likely vanish next year thanks to a court-ordered redrawing of the state’s district maps.
Yet the president and his chief allies invested tremendous time and resources in keeping the seat in Republican hands, mindful the contest could be used to measure his lasting appeal among white, working-class voters.
The White House scrambled to rally voters behind Mr Saccone, who cast himself as the president’s “wingman,” but he struggled at times to connect with the blue-collar coalition that fuelled Mr Trump’s victory little more than a year ago.
Mr Lamb, a 33-year old former federal prosecutor, asserted his independence from the Democratic Party, courted labour backing and focused on local issues.
Mr Trump campaigned for Mr Saccone last weekend, urging voters not to “be conned by this guy Lamb”.
Democrats must take 24 Republican-held seats this autumn to seize control of the House, and months ago few had counted on the district to be in play. The seat has been in Republican hands for the past 15 years.