Republican Dan Bishop pulled out a narrow win in North Carolina’s 9th Congressional District on Tuesday, giving the GOP a victory in a district that President Trump won easily in 2016 but which proved to be a fierce battleground in unusual back-to-back House campaigns.

With 99 percent of precincts reporting, Bishop led Democrat Dan McCready by more than two percentage points in a special election called after allegations of fraud against McCready’s initial GOP opponent upended a razor-thin election last November.

Bishop’s victory came one day after Trump and Vice President Pence campaigned in the district to help boost the state lawmaker in the surprisingly competitive race in a district Trump won by 12 percentage points in 2016. All three Republicans cast the race as a chance for voters to send a message in support of the president and against the liberal policies of national Democrats.

In remarks to supporters Tuesday, Bishop thanked Trump for his support and said his victory was a “first step toward taking back the House of Representatives in 2020.”

“I hope the Democrats in Washington are watching this incredible victory and realize what they’re doing is not working,” he said. “Let’s hope they see this as an opportunity to stop playing presidential politics and come to the table to work with us and work with this president.”

But Democrats warned that even a two-point Republican victory was hardly good news for the GOP in a district where Trump easily won and Republicans have been elected to Congress consistently since 1962.

“Tonight’s razor-thin result in this ruby-red district solidifies the fact that Democrats are pushing further into Republican strongholds and are in a commanding position to protect and expand our House majority in 2020,” said Rep. Cheri Bustos (D-Ill.), chairwoman of the Democratic Congressional Campaign Committee.

Voters in the state’s heavily Republican 3rd Congressional District also went to the polls Tuesday, electing Republican Greg Murphy over Democrat Allen Thomas by a 24-point margin to succeed the late congressman Walter B. Jones (R).

The outcome in the 9th District, meanwhile, was the culmination of a political saga that stretched over more than two years — exploding into allegations of ballot fraud that prompted state and federal investigations and the nullification of November’s general election. Republican nominee Mark Harris, who hired the consultant accused of perpetrating the fraud, dropped out, making way for Bishop’s nomination in the repeat election.

On Tuesday, McCready won solid margins in affluent neighborhoods of Charlotte and the suburbs immediately south and east of the city. But he lost ground vs. his November showing in rural counties east of the city — indicating a deepening divide between conservative rural voters and the suburban voters increasingly flocking to Democrats.

Trump on Tuesday night took credit for Bishop’s victory in a tweet: “Dan Bishop was down 17 points 3 weeks ago. He then asked me for help, we changed his strategy together, and he ran a great race. Big Rally last night. Now it looks like he is going to win.”

McCready held a significant lead in early returns Tuesday, thanks to a Democratic turnout advantage in early voting. But that lead steadily eroded as votes were counted, reflecting a successful GOP strategy of boosting last-minute turnout with visits from Trump on one side of the district and Pence on the other.

“Trump pushed him over the top, absolutely,” said Rep. Richard Hudson (R-N.C.), who represents the neighboring 8th District and joined Trump in campaigning for Bishop on Monday. “Turnout is everything when you have a close race.”

McCready in his concession speech Tuesday thanked his supporters for sticking with him through a campaign that ultimately lasted for more than two years. He said it was important that his campaign continued fighting through the fraud allegations.

“The people of North Carolina stood up, and we faced down the full force of election fraud and voter suppression,” he said. “When the people in power . . . perpetrated the largest case of election fraud in recent American history, we fought back, and we won. We were not successful tonight, but I want you to remember that victory postponed is not defeat.”

The stakes for the special election were substantial — for one, measuring whether Trump had been able to recover any support in suburban areas that drove Democrats’ sweeping 2018 gains in the House. The results indicated that while the suburbs might not be warming to Trump, rural conservatives remain as loyal as ever.

“The results tonight are the clearest sign yet that the left’s embrace of socialism is putting even their strongest and best-funded candidates in dire jeopardy,” said Dan Conston, president of the Congressional Leadership Fund, a GOP super PAC that spent millions to elect Bishop.

Bishop, 55, is a Trump loyalist who came to prominence in 2016 by writing a controversial bill, enacted and then repealed, that would have dictated which bathrooms transgender people could use.

McCready, meanwhile, is a 36-year-old former Marine Corps officer and solar-energy investor who had been running for more than two years on a centrist platform.

Hudson played down the close result: “I don’t think it’s an indictment of Trump that it’s close. I think it’s just the fact that their guy is a talented campaigner who has been running a long time, spent a lot of money and is running away from being a Democrat.”

For Democrats, Bishop’s win could send signals that 2018’s “blue wave” could be ebbing in a presidential cycle, with Trump driving higher turnout among Republicans, offsetting the suburban erosion. It may also spark a round of second-guessing about national party strategy after Democratic groups spent millions of dollars in the final week to get McCready over the finish line.

At his campaign rally in Fayetteville on Monday, Trump told the crowd, “Tomorrow is your chance to send a clear message to the America-hating left.”

In Monroe, N.C., voter Carolyn Slover, 27, said Tuesday that Trump’s visit “made me want to vote for Dan Bishop. It shows who he’s for and how they are a partnership.”

Several voters in Cumberland County who backed Bishop said Tuesday morning that Trump didn’t influence their choice but rather that the Democratic Party did.

“It wasn’t so much about voting for him as it was voting against the Democrats,” said Tom Driggers, 76. “I simply don’t believe in most of their policies. I’m like George Bush; I’m a conservative with common sense.”

Wayne Canady, 71, said he didn’t share any values with Democrats.

“You name an issue and I’m against their stance. All the troubles in the world stem from communism or socialism. Look at the Democrats’ policies,” Canady said.

In Monroe, N.C., John Kirkpatrick, 36, said he backed McCready.

“I don’t necessarily vote for a party. I vote for an individual,” he said. “At the end of the day, I don’t agree with all that candidates represent, but I try to choose the best candidate to serve my community.”

The 9th District stretches from the affluent Charlotte suburbs east to poor rural counties and north to the military stronghold of Fayetteville. The race revolved largely around support for Trump and, to a lesser degree, was influenced by the fallout from the fraud scandal.

The state elections board found evidence that Leslie McCrae Dowless — a contractor for Mark Harris, McCready’s initial Republican opponent — illegally collected and in some cases filled out absentee ballots for voters in rural Bladen County, many of them elderly and African American. The board ordered a new election in January, and Harris, who had led in unofficial returns by 905 votes, opted not to run again.

“I’m dressed in blue today and voted for Dan McCready because he was robbed last time,” said Jill Salas, 51, a voter in Monroe.

Spending on the race approached $20 million, making it one of the most expensive special elections in U.S. history. McCready’s campaign spent nearly $5 million, while Bishop’s spending approached $2 million. Outside Republican-aligned groups added $6.8 million, while Democratic groups spent about $3.5 million, according to federal records compiled by the Center for Responsive Politics.

Much of that spending was funneled into TV attack ads. Republicans targeted McCready’s business record, suggesting that he prospered at taxpayers’ expense by lobbying state officials for tax breaks. Democrats, meanwhile, accused Bishop of doing the bidding of health insurance companies and the pharmaceutical industry.

Felicia Sonmez contributed to this report.