Updated

Kansas state Treasurer Ron Estes held off a stronger-than-expected challenge from Democratic civil rights attorney James Thompson Tuesday night as the GOP won the first special congressional election since President Trump's inauguration.

The election was held to fill the House seat vacated by CIA Director Mike Pompeo, a former three-term representative of Kansas' 4th district.

Estes won 53 percent of the vote to 46 percent for Thompson. The Republican's margin of victory was just over 8,000 votes. By contrast, Pompeo won re-election in November by 31 percentage points and 85,000 votes.

In a speech to supporters in Wichita, Thompson vowed that he would run for the seat again in 2018 and argued that the result was evidence that no Republican district is safe.

The race had been closely watched nationally for signs of a backlash against Republicans or waning support from Trump voters in a reliably GOP district. Trump won 60 percent of the votes cast in the 17-county congressional district this past November.

The president himself entered the fray Monday with a recorded get-out-the-vote call on Estes' behalf and tweeted his support on Tuesday morning.

Other nationally known Republicans pitched in over the final days of the race. Sen. Ted Cruz of Texas campaigned for Estes Monday in Wichita, while Vice President Mike Pence also recorded a get-out-the-vote call. The National Republican Congressional Committee spent roughly $90,000 in last-minute TV and digital ads.

Thompson reckoned that the high-profile support for Estes helped push him over the top, and claimed he could have won had national Democrats rallied to him sooner. Readers of the liberal blog Daily Kos donated more than $200,000 to Thompson in the final days of the race. Thompson was also backed by Our Revolution, the group that grew out of Sen. Bernie Sanders' 2016 presidential campaign.

"You fight," Thompson said when asked what the results should show Democrats. "You play every game."

All those GOP calls prompted Charlene Health, a 52-year-old homemaker and Republican in Belle Plaine, to cast a ballot for Estes.

"I wasn't even going to vote," she said as she left her polling site Tuesday morning. "I finally did. I realized this was important."

Alan Branum, 64, a retired construction worker is a Wichita Democrat who voted for Estes and plans to change his party affiliation to Republican since he leans more conservative. He thinks Trump has been been doing fine so far.

"I don't think it is fair people condemn him," he said of the president. "He hasn't been in long enough to make a judgment. People need to give him some time."

Estes supported Trump last year and backs the president's policies. He supports the repeal and replacement of the Affordable Care Act, backs funding for a wall on the border with Mexico, opposes funding for Planned Parenthood, and does not believe an independent investigation into Russian hacking of the election is needed.

Lucy Jones-Phillips, a 31-year-old insurance representative and Democrat, acknowledged she doesn't vote in every election, but said she voted for Thompson because she wanted to ensure supporters of Gov. Sam Brownback are not in office. She was especially upset when the Republican governor recently vetoed Medicaid expansion.

"I can't stand Brownback," she said as she left her polling site in Belle Plaine.

Thompson tried to tap into voter frustration with Brownback throughout the campaign, tying the state treasurer to the unpopular Republican governor. Thompson has called the Kansas congressional election more of a referendum on Brownback than on Trump.

But Thomas Hauser, 67, of Belle Plaine, a Republican who works in the information technology industry, said he crossed party lines in Tuesday's election to vote for Thompson. He also didn't vote for Trump in the last year's general election. Thompson appealed to Hauser in part because both men are ex-military but also because "I don't believe in the (GOP) line."

Republicans have represented the south-central Kansas district since 1994. The district has been hard hit by the downturn in the agricultural economy and the loss of hundreds of well-paying, blue-collar jobs in aircraft manufacturing plants.

With Estes' victory, Republicans are now defending three GOP-leaning seats in upcoming special elections in Georgia, Montana and South Carolina. Democrats are protecting a seat in a liberal California district.

Fox News' Lee Ross and The Associated Press contributed to this report.