Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Republican Ron Estes defeated his Democratic rival in a high-profile special congressional election in Kansas Tuesday that had been seen as a referendum on President Donald Trump.

But the narrower-than-expected outcome may worry Republicans across the country as they try to decipher how much Trump's low approval ratings might hurt his party's candidates.

Trump and former Rep. Mike Pompeo, who vacated the seat to become CIA director, had both won the district by nearly 30 percentage points in November.

On Wednesday morning, Trump tweeted about the GOP victory.

Great win in Kansas last night for Ron Estes, easily winning the Congressional race against the Dems, who spent heavily & predicted victory! — Donald J. Trump (@realDonaldTrump) April 12, 2017

But Estes dramatically underperformed past Republican candidates in the district, with Democrat James Thompson behind Estes by just 7 points with all precincts reporting, based on unofficial results posted online by the Kansas Secretary of State’s office. Estes won with 53 percent of the vote, and Thompson got 46 percent, according to the unofficial results.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

For that, Democrats are declaring victory.

"Kansas' 4th Congressional District is ruby red and should never have been on the table — this massive swing from the 2016 presidential results should set off alarm bells for House Republicans. It’s not just independents, but clearly Republicans who are bailing on the GOP, and very few districts are safe," said Meredith Kelly, the communications director for the Democratic Congressional Campaign Committee.

Kansas 4th District congressional Democratic candidate James Thompson. Fernando Salazar / The Wichita Eagle via AP

The special election in Kansas’ conservative 4th congressional district attracted a late surge of attention when Republicans, spooked by weak polling and early turnout data, staged a last-minute intervention in what was expected to be a sleepy race.

Trump, making his first personal investment in an election since he was sworn into office, recorded robocalls and tweeted his support for Estes on Tuesday morning.

Democratic activists, already eyeing an upset in next week’s special election in Georgia, let their hopes get raised, pouring over $200,000 into Thompson's campaign over the past few days. It had raised not much more than that in the previous three months combined.

Democratic operatives all along were tempering expectations, privately saying they saw no path to victory in crimson Kansas — but they were happy to watch Republicans squirm.

The district is home to Koch Industries, the company owned by billionaire GOP donors Charles and David Koch.

National Democrats may now take heat from their base for not doing more. The campaign arm of House Democrats and the Democratic National Committee both made a last-minute get-out-the-vote pushes, but otherwise stayed away the race.

RELATED: Trump looms over Georgia special election

Party strategists dispute how much they could have done, and some say help would have backfired, since it would have prompted Republicans to take the race more seriously as well.

The late GOP infusion of resources was more about bolstering Estes’ margin of victory than holding off a loss, Republican sources say, a concern that appear justified.

Political observers will now turn their attention to the Atlanta suburbs, where Democratic newcomer Jon Ossoff is hoping to prevail against a divided GOP field in a slightly less conservative congressional district next Tuesday.

After that, comes a May 25 election in Montana to replace former Rep. Ryan Zinke, now Trump’s Interior Secretary. Democrat Rob Quist, a country singer, is mounting an underdog campaign against Republican Greg Gianforte in the state-wide congressional district.

All three special elections are playing out in Republican turf. But Democrats, fired up by opposition to Trump, are looking for ways to send a message to the White House, and praying for upsets in these unpredictable and low-turnout special elections.