Republican Troy Balderson claimed victory over Democrat Danny O’Connor in a widely watched special congressional election Tuesday to represent Ohio’s 12th District in the House of Representatives.

With all precincts reporting, Balderson, an Ohio state senator who closely linked himself to President Trump — appearing with him at a rally last weekend — held a 0.9 percent lead over O’Connor, a county recorder and moderate Democrat.

Although the razor-thin race had not been called by any major news organizations, and was automatically going to a recount, Balderson, 56, delivered a victory speech and both the National Republican Congressional Committee and Trump put out statements declaring victory for their preferred candidate.

“After my speech on Saturday night, there was a big turn for the better,” Trump said in a tweet. “Now Troy wins a great victory during a very tough time of the year for voting. He will win BIG in Nov.”

Balderson gave a speech thanking Trump for his help in campaigning, saying he himself had “big shoes to fill” in Congress and that he would “do everything I can to make America great again.”

However, O’Connor, 34, onstage at his campaign headquarters in the central Ohio district, said the race was a “tied ballgame,” with a rematch due in November’s regular congressional election for the seat, which opened up when GOP Rep. Pat Tiberi resigned in January.

“We’re not stopping now,” O’Connor said. “Tomorrow we rest and we keep fighting through to November.”

It was a match-up many Democrats compared to the March special election in a red district in western Pennsylvania, in which the 34-year-old Democratic candidate, Conor Lamb, pulled off a victory.

O’Connor seemed to have the momentum in the run-up to Tuesday’s election.

He had pulled ahead in one poll, despite the district leaning heavily Republican, with no Democrat having been elected to Congress there in more than 30 years.

Trump won the district by 11 points in 2016.

Balderson had both Ohio Gov. John Kasich, a strong Trump critic, and the president behind him.

O’Connor needed Franklin County — which includes the state capital, Columbus — to come out strongly for him in order to topple his Republican rival.

He also needed good numbers in neighboring Delaware County. But with 99 percent of precincts reporting, Delaware County had tilted in Balderson’s favor.

Meanwhile, in Michigan, Trump also had a good night. His pick for governor, Bill Schuette, the state’s attorney general, easily won the GOP primary.

The president’s Senate pick, John James, whom Trump called a “potential Republican star,” also won. James also had help in the state from musician Kid Rock, who had once flirted with running against incumbent Democratic Michigan Sen. Debbie Stabenow, who ran unopposed in the Democratic primary.

Meanwhile, progressive duo Sen. Bernie Sanders (I-Vt.) and Bronx/Queens Democrat Alexandria Ocasio-Cortez saw their chosen Michigan Democratic gubernatorial primary candidate, Abdul El-Sayed, lose.

El-Sayed, who in the general election could have been in line to become the nation’s first Muslim governor, fell to fellow Democrat Gretchen Whitmer.

With Post wires