(Reuters) - Democrats preached optimism on Wednesday after losing a special congressional election in North Carolina, citing suburban gains and the close margin in a district President Donald Trump won by 12 percentage points as signs of strength going into 2020.

Dan McCready, the Democratic candidate in the special election for North Carolina's 9th Congressional District, acknowledges cheers from his supporters as he takes the stage to deliver his concession speech with his wife Laura after his loss in the contest, in Charlotte, North Carolina, U.S., September 10, 2019. REUTERS/Jonathan Drake

But the results from Tuesday’s vote also showed a deepening divide between rural voters and the Democratic Party in the state’s 9th District - a schism Trump and other Republicans are certain to exploit in next year’s elections.

“There are still Blue Dog Democrats in the district who feel more and more that the party has left them with the super-liberal views,” said Phillip Stephens, chairman of the Republican Party in Robeson County, which sits in the 9th District.

“I should know, I was one of them,” he said, referring to centrist and conservative Democrats.

North Carolina is expected to be among a handful of battleground states in the November 2020 presidential election. For Trump, who won the state by almost 4 points in 2016, North Carolina is considered a must-win among many political pundits, while offering Democrats an avenue to potentially capture the White House.

Republican Dan Bishop defeated Democrat Dan McCready by 2 percentage points on Tuesday to fill the last remaining seat from the 2018 election. McCready also narrowly lost to Republican Mark Harris in 2018, but the results were thrown out by the state’s election board after a ballot-fraud scandal cast doubt on their legitimacy.

Both parties viewed the election do-over as something of a test run for next year’s contests, when Trump will seek another four-year term and Republicans will try to win back the U.S. House of Representatives from Democrats. Trump and Vice President Mike Pence rallied for Bishop in North Carolina on the eve of the vote.

Bishop, a conservative state legislator, ran on a Trump platform and painted his opponent as a far-left liberal. McCready, a small-business owner and U.S. Marine Corps veteran, rarely mentioned Trump and portrayed himself as a moderate.

McCready won the densely populated Charlotte suburbs in Mecklenburg County by 12 percentage points, continuing the national trend of traditionally Republican suburban areas shifting toward Democrats as highly educated voters tire of Trump.

Slideshow ( 5 images )

Those gains were not enough to overcome a poor performance in rural counties like Robeson and Bladen.

President Barack Obama won Robeson County, a rural region once dominated by Democrats, in 2008 and 2012 before it went to Trump in 2016. In the 2018 election that was eventually overturned, McCready won the county by roughly 15 percentage points, but squeaked out just a 1-point victory in Tuesday’s contest, election records show.

Stephens, the local Republican chairman, credited his party’s turnaround to a strong messaging campaign that linked McCready to the party’s more liberal policies and a candidate not afraid to express his conservative views.

Democratic voter registrations in the county have dipped to about 62% from 80% in 2004. Most of the defections have registered as unaffiliated with a party, a prized cohort who can still participate in nominating primaries.

LESSONS FOR 2020

Kyle Kondik, managing editor of Sabato’s Crystal Ball, which tracks congressional races nationally, said the victory would allow Republicans to enjoy the power of incumbency in the district and avoid having to spend millions to dislodge McCready.

Republicans must contend, however, with the fact that Democrats pulled off a 10-point swing in the district from 2016, said Eric Heberlig, a political science professor at the University of North Carolina at Charlotte.

“If Republicans think this means everything is in good order, they are missing the flashing lights as well,” he said.

Turnout and interest in North Carolina will be high next year. Democratic Governor Roy Cooper and U.S. Senator Thom Tillis, a Republican, are both making their first re-election bids in what are expected to be tight races.

Those contests are expected to attract record spending by the campaigns and outside groups, political experts say.

Democratic leaders in North Carolina and Washington said on Wednesday they would continue their outreach to rural voters, arguing their party’s agenda was designed to improve life for all Americans.

Asked how important North Carolina is to Trump’s re-election, Kayleigh McEnany, the campaign’s national press secretary, said all states were important and that the campaign’s data-intensive efforts would help direct spending.

“But,” she added: “We are holding the Republican National Convention in Charlotte, so I think that tells you how important we think it is.”