(Reuters) - Republican Dan Bishop won a special U.S. congressional election in North Carolina on Tuesday, turning back a vigorous Democratic challenge to save a longtime stronghold for President Donald Trump’s party.

With 99% of precincts reporting, Bishop, a 55-year-old state senator for whom Trump campaigned, led Democrat Dan McCready, a 36-year-old veteran of the Marines, 50.81% to 48.59%, the state board of elections said.

North Carolina’s 9th congressional district, a suburban-rural area in the southeastern part of the state, has been represented by Republicans in Congress since the 1960s and voted for Trump by about 12 percentage points in 2016.

But Democrats thought they had a chance to flip it and build on the majority they won in the House of Representatives last year. McCready lost by a slim margin in 2018 before state officials ruled the election was tainted by an absentee-ballot fraud scheme that benefited his Republican opponent, Mark Harris, and ordered a new vote. Harris did not run again.

Both parties poured millions of dollars into the election do-over, with the final contest of the 2018 congressional midterms being watched for signs of their prospects in 2020.

Trump, who flew to the district on Monday night to rally the Republican base for Bishop, moved immediately to take credit.

“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,” Trump wrote on Twitter.

The Trump campaign national press secretary, Kayleigh McEnany, said Trump’s endorsement “has the power to change the trajectory of political races ... Dan Bishop won this evening & Trump’s endorsement carried him to victory!”

On Monday, McEnany said the Trump campaign did not believe the results of the special election would be predictive for 2020.

Slideshow ( 24 images )

Republicans also won a special election in another district in North Carolina where they had been expected to do so. Republican Greg Murphy defeated Democrat Allen Thomas for a seat left vacant by longtime Republican Representative Walter Jones’ death in February by 61.74% to 37.47%, according to the state board of election results.

Bishop thanked Trump and vowed to support the president’s agenda in Washington. He said his victory should send a message nationwide that voters were rejecting the “radical, liberal policies being pushed by today’s Democratic Party.”

“Tonight was the first step toward taking back the House of Representatives in 2020 to keep this country on a path of prosperity and strength,” the Republican told a cheering crowd.

SIGNS FOR 2020 ELECTIONS

Republicans hope the victory will help the party launch a comeback effort to wrest the House away from Democrats after losing 40 seats and overall control in House elections last November.

A wave of recent Republican retirements from the House has fueled speculation that Republicans fear they will not win the 19 seats they need to regain the majority in that chamber next year.

Democrats had been hoping to show that 2018 was not their high-water mark and looked to further weaken support for Trump and his Republicans in suburban areas.

Political analysts noted McCready did improve his standing over the previous election in the suburbs of Charlotte. But a poor showing with rural Trump-supporting Democrats cost the party a pickup, analyst David Wasserman of the Cook Political Report said on Twitter.

Slideshow ( 24 images )

The chairwoman of the Democratic congressional campaign arm, Representative Cheri Bustos, said Democrats had fallen “an inch” short but that Republicans had required millions in spending and a Trump rally just to “scrape by.”

“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,” she said.

Bishop campaigned on taxes, the economy and immigration. He echoed Trump’s political themes, asserting that McCready “admires socialism” and linking him to the “Squad,” a group of progressive Democrats in the House who Trump has repeatedly attacked.

McCready, a small businessman, sought to steer the campaign discussion away from Trump and onto issues such as healthcare, education and teacher pay.

He labeled Bishop, who sponsored a 2016 measure in the state legislature restricting public restroom access for transgender people, as a “career politician.”

“We may not have won this campaign, but that does not mean that we were wrong,” McCready said in his concession speech Tuesday night. “And as long as there are people who thrive off our division, there is still work to be done.”