WASHINGTON — The GOP breathed a huge sigh of relief Tuesday night when Republican Ron Estes eked out a narrow win to become the next Representative of the 4th District of Kansas.

It was a victory that was at once a relief and an embarrassment for Republicans. In November, Donald Trump won the district by 27 percent; on Tuesday, Estes beat Democrat James Thompson by single digits. And that was after a last minute infusion of cash from national Republicans, robo-calls from both Trump and Vice President Mike Pence encouraging Republicans to vote, and a Monday in-town rally with Texas Sen. Ted Cruz.

“We just had to scare everyone out to vote,” Kansas GOP Chairman Kelly Arnold told BuzzFeed News.

Tuesday’s vote marked the first congressional election since Donald Trump won the presidency last November. And while Democrats can’t claim another House seat, there is cause to celebrate. Thompson’s campaign was able to tap into the anger and energy that has buoyed the left since Trump’s election in November, something the Democrat readily admitted he himself wasn’t ready for. And Republicans were unable to match it.

The fact that Democrats were able to hold Republicans to a single-digit victory in a race that never should have been on the board in the first place bodes well as they move onto races where the playing field is more favorable.

They won’t have to wait long: Democrats get another bite at the apple in exactly one week in another special election in Georgia’s 6th congressional district. There, Trump won by just one point in November, though the district has sent a Republican to Congress since Newt Gingrich was elected in 1978. Democratic candidate Jon Ossoff has been buoyed there by the same forces that helped Thompson in Kansas— and then some. He raised $8.3 million, an obscene sum of money that, combined with a huge field of GOP candidates splitting the party’s vote, has left Georgia Republicans gasping.

Republicans and Democrats caution against reading too much into the results of a single special election, where turnout is usually lower than in regularly timed elections, leaving room for all manner of weirdness. By the time the midterm elections come around in 2018 and turnout returns to normal, the seat is likely to be much safer for Republicans.

And while the energy on the Democratic side is certainly in part a response to Trump’s presidency, he was not the root cause of the problems for the GOP on Tuesday. Republicans in Kansas's 4th District were trying to grapple not only with an unfavorable national environment, but an uninspiring candidate running a campaign that left Republicans cold. Nationally and in the state, Republicans panned Estes’s campaign strategy and lamented that national Republicans needed to get involved in the first place.

What’s more, Kansas’ Republican Gov. Sam Brownback’s approval ratings are in the toilet – sitting at 27 percent, according to a Morning Consult poll. Other Republicans running in Kansas have struggled to escape his long shadow, and Estes was no exception.

Estes remained the favorite given the Republican tilt of the district, but it was nothing close to the sure thing either party expected at the outset.

Thompson's ability to keep the race close in such a red district is a major narrative victory for Democrats, and a morale boost heading into an even more contested special election in Georgia’s 6th District next week. And Republicans will have to figure out how to contend with a newly energized left heading into 2018.

“Nobody gave us any credit. I mean, they said, ‘Oh, you’re a long shot, you can’t win,’” Thompson recounted Monday. “And for us we’ve already done the impossible in that we’ve made it competitive. So if we can win, that just caps it off.”

Thompson, for his part, was already talking about trying to recapture the magic in 2018 if he lost.

“If I lose, then we’re gonna sit down and figure out where I want to run,” he told BuzzFeed News Monday. “And most likely it would be turning around and going into the 2018 race and having the full time period to prepare for an election, prepare for taking Estes out.”

Both parties spun the race as a win on Tuesday night. But the internal party recriminations have already begun. National Republicans have little nice to say about Estes and his campaign, or the fact that they had to send the cavalry into a what should have been a safe district. And on the Democratic side, questions are swirling over whether the DCCC should have done more to help push Thompson over the edge. It isn’t a high bar: the Democratic Congressional Campaign Committee ignored the race until Monday, when they launched some last-minute get out the vote phone calls.

“I don’t think they were” prepared to deal with it, Thompson said of national Democrats Monday. “The DNC and the DCCC are making huge mistakes by discounting ultra-red states just because they haven’t been successful in recent years,” he added. “I think that’s all the more reason to concentrate on those states.”

The DCCC, for its part, crowed about Thompson’s close loss on Tuesday night.

“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,” DCCC communications director Meredith Kelly said in a statement.

National Democrats’ efforts will be on full display next Tuesday in Georgia, where they have invested both money and personnel to get Ossoff, the 30-year-old Democrat, over the finish line.

But looking ahead to the 2018 midterms, one thing is quite clear: Republicans have to figure out how to match the enthusiasm on the left — if Democrats can manage to sustain it.