Republican Greg Gianforte claimed a narrow victory in Montana’s closely watched special election for the state’s at-large congressional seat, defeating Democrat Rob Quist in a race that is likely to be mined for clues about how the voting electorate feels about the political turbulence of Donald Trump’s young presidency heading into next year’s midterm elections.

With 83 percent of precincts reporting, Gianforte led Quist by roughly 7 points in the race.

The results came after a wild 24 hours in the race, in which Gianforte, a billionaire technology entrepreneur from Bozeman, was charged with misdemeanor assault after he allegedly “body slammed” Ben Jacobs, a reporter for the Guardian newspaper, at a campaign event on Wednesday just hours before voters headed to the polls.

Speaking to supporters at his victory party, Gianforte publicly apologized for the altercation. “Last night, I made a mistake, and I took an action that I can’t take back,” Gianforte said in his first public statement on the incident. “I should not have responded the way I did, and for that I am sorry.”

“I should not have treated that reporter that way,” he added, apologizing to Jacobs by name.

The incident, which a Gianforte campaign aide initially blamed on Jacobs, prompted the state’s three largest newspapers to rescind their endorsements of the GOP candidate, though it’s unclear if the decision had any clear impact on the race. In a state known for its long tradition of early voting, roughly half of the estimated total ballots in the race had already been cast by the time the scandal broke, with most favoring Gianforte.

The special election was considered a crucial first test for Republicans looking ahead to next year’s 2018 midterm elections on the tricky question of whether it is politically safer to stick with Trump or run against him. Gianforte, who narrowly lost a gubernatorial bid last year after keeping Trump at a distance, did just the exact opposite in this race, fully embracing the GOP president’s playbook.

Story continues

He endorsed the president’s decision to fire James Comey, the former FBI director, and expressed skepticism about investigations into Russian attempts to influence the presidential election. Like many Republicans around the country, Gianforte revamped his public remarks to embrace familiar catchphrases of the Trump lexicon, insisting he was running to help the GOP president “drain the swamp” and to “make America great again” — lines he emphasized again in his victory speech.

Democratic Congressional candidate Rob Quist delivers his concession speech to supporters alongside family members on May 25 in Missoula, Mont. (Photo: Justin Sullivan/Getty Images)

Though their candidate lost, Democrats still tried to claim a moral victory in the race, pointing out Gianforte’s slim margin of victory in a heavily conservative state where Trump won by 20 points last November. Though public polling in the race was scarce, Gianforte had entered the race strongly favored to win over Quist, a well-known singer-songwriter who was running his first political campaign, only to see the race become a nail-biter in recent weeks against the backdrop of Trump’s political struggles.

While out-of-state Democrats seized on his candidacy as a chance to gain footing against Trump, Quist was massively outspent by Gianforte and his allies, who poured at least $7.6 million into the race, mostly on television ads. As polls tightened in recent weeks, GOP heavyweights were dispatched to the state, including Vice President Mike Pence and the president’s son, Donald Trump Jr. On Tuesday, Trump himself interceded, recording a robocall on Gianforte’s behalf. That came after similar recorded calls from Republican Sens. Ted Cruz of Texas, John McCain of Arizona and Marco Rubio of Florida.

While Democrats failed to pull off the upset they had been hoping for, the race could offer significant insights to party members in red states as they try to position themselves to win back the working-class and rural Americans widely credited for Trump’s victory last year.

As noteworthy as Gianforte’s passionate embrace of Trump was, it was equally notable how little Quist talked about the GOP president. Though he campaigned against many of Trump’s policies, including Republican efforts to overhaul the nation’s health care plan, Quist rarely mentioned Trump by name. While he campaigned with Vermont Sen. Bernie Sanders in the final days of the campaign, Quist shunned other help from national Democrats and instead positioned himself as an independent who would try to find common ground with Republicans on helping struggling Americans who feel left behind by Washington. It was a strikingly similar message to that which helped Trump win the presidency last year.

While Republicans were relieved to keep Montana’s seat in GOP hands, the results were met with mixed feelings amid private grumbling over Gianforte’s weakness as a candidate and the worry that legal troubles related to his alleged assault of a reporter were only likely to add more problems for a party already weighted down by the drama of an unpredictable president whose administration is clouded by investigations.

Gallatin County Sheriff Brian Gootkin answers questions during a press conference on May 25 in Bozeman, Mont. (Photo: Rachel Leathe /Bozeman Daily Chronicle via AP)

Though Gianforte heeded public calls from Republicans including House Speaker Paul Ryan to apologize for his behavior toward Jacobs, the issue is unlikely to go to away. He still faces a June 7 court date in Montana to answer an allegation that he “purposely or knowingly” caused “bodily injury to another.”

That potentially creates an awkward situation for GOP lawmakers who will have to interact with the businessman in Washington.

Speaking to supporters late Thursday night in Bozeman, Gianforte seemed not only to try to put Montana voters at ease but also to send a message to his new GOP colleagues by vowing that he would keep his head down and work in Washington.

“You deserve a congressman who stays out of the limelight and just gets the job done,” he said.

Read more from Yahoo News: