Republican Dan Bishop pulled off a narrow victory in a closely-watched North Carolina special congressional election — a day after President Trump pushed his supporters to vote for the candidate at his packed campaign rally.

Bishop, a conservative who has been a state Senator since 2017, defeated Democrat Dan McCready for the vacant House seat in the state’s 9th Congressional District.

Trump threw his weight behind Bishop — and had close eyes on the race in a district where the president breezed to victory in 2016 by 11 percentage points.

At a Trump campaign rally in Fayetteville on Monday night, the president encouraged the crowd to back Bishop.

Trump even invited Bishop up on stage, where the GOP-candidate said: “Go out and vote for right Dan, vote for Dan Bishop.”

On Tuesday, the president continued his support, blasting out four tweets telling voters to cast their ballots for the GOP candidate.

“Vote today for Dan Bishop. Will be great for North Carolina and our Country!” read of Trump’s tweets.

Bishop’s victory isn’t all that surprising, as the district has been under GOP control since 1963.

But political insiders kept a close eye on the race to see if McCready could continue a string of 2018 victories by Democrats in suburban districts of red states including Texas, Oklahoma and Kansas.

Such a victory would have been seen as a blow to Trump — and the GOP’s prospects of regaining control of the House in 2020.

Bishop is a critic of LGBTQ rights who once compared gay rights activists to the Taliban, and spearheaded North Carolina’s so-called “bathroom bill,” which banned transgender people from using public restrooms otherr than those designated for their biological sex as defined on their birth certificates.

It was subsequently overruled by a federal judge in Asheville in a ruling affirmed by the Supreme Court — but not before costing the state millions in canceled business events.

McCready, a moderate and former Marine captain, during his campaign vowed to protect Social Security and Medicare, cut taxes on the middle class, end gerrymandering, renegotiate trade deals and reduce military intervention overseas.

He was a familiar name in the district, as he ran for the seat in last November’s election.

In that contest, his Republican challenger, Mark Harris, appeared to win by fewer than 1,000 votes. But allegations of voter fraud caused the state’s Board of Elections to call Tuesday’s special election.

Harris chose not to run again.