(CNN) Republicans won a special congressional election Tuesday in the suburbs west of Phoenix, holding on in a reliably red district where Democrats launched a well-organized but long-shot bid to flip the seat.

However, the relatively close margin of victory in a district Donald Trump won by 21 points in 2016 signals trouble for Republicans heading into the midterm elections in November.

"This isn't a great result," one senior national Republican operative bluntly told CNN as results ticked in.

Republican Debbie Lesko, a former state senator, bested Democrat Hiral Tipirneni, a physician, in Arizona's 8th Congressional District. With 94% of the vote counted, Lesko led Tipirneni 52% to 47%.

The seat was opened when Republican Rep. Trent Franks resigned in December amid sexual harassment allegations.

Lesko will fill the seat through the end of this congressional term in January and must run for re-election in November to continue serving.

Even though Republicans avoided another stinging loss in a special election after losing a US Senate race in December in Alabama and Pennsylvania's 18th Congressional District in March, the party's top operatives in Arizona and across the country worried that the narrow margin was a signal of losses to come.

"This was not supposed to be this close," the senior Republican said as representatives from the Lesko campaign touted the win for their candidate. "We really can't blame anything. We got killed among independents. It shouldn't have been this close."

Democrats didn't wait for the final margin before trumpeting the narrow loss as a sign of good things to come for the party. They touted the fact that Tipirneni kept it close in a district where Democrats didn't even put up a candidate in 2014 and 2016, and they argued the slim margin shows their message is resonating in the era of Trump.

Democrats didn't think they would win the race. Arizona's 8th Congressional District has all the hallmarks of a place Republicans should easily win and there are around 78,000 more registered Republicans than Democrats in the area.

But in a year where Democrats, buoyed by anti-Trump fervor, have consistently overperformed their Republican counterparts, the party will look at the loss as a sign that a blue wave is about to crash on Republicans in the general election later this year.

Their thinking heading into the race went like this: If Tipirneni keeps it close with Lesko in a district that Trump won by more than 20 points, Democrats in Arizona stand to make significant gains in key races later this year like a closely watched contest for the state's open Senate seat, a chance to challenge Arizona's Republican governor and a winnable open House seat. Trump won Arizona overall by only roughly 3 points in 2016.

"Every Republican elected in Arizona was just put on notice," a Democratic aide in Arizona told CNN. "Obviously the results are still coming in a little bit but this speaks volumes for what the fall is going to look like in Arizona."

In a statement on Wednesday, Tipirneni conceded the race and said she would run again in November

"Now that nearly all of the votes have been counted, we know that the special election goes to our opponent," she said. "I congratulate Debbie Lesko on a hard-fought campaign, and wish her good luck in Congress."

The race largely hinged on health care, with Tipirneni leaning heavily on her medical background and proposing universal coverage through Medicare expansion. Lesko cast Tipirneni's plans as too liberal for the district and attempted to tie herself to Trump throughout the campaign, namely by backing his plan to build a wall along the US-Mexico border and celebrating the Republican-backed tax reform.

Compared with the race earlier this year that saw Democrat Conor Lamb's unlikely win in suburban Pittsburgh, spending in the Arizona district was relatively minimal and Trump kept his distance.

Tipirneni raised $664,920 during the race, over $100,000 more than Lesko's $539,403. However, that shortfall was made up by outside Republican groups that pumped more than $1 million into the contest for a mix of media and turnout services.

The Democratic National Committee spent $175,000 in the race on online fundraising, digital ads and staff on the ground, including a $75,000 grant to the state party for all its 2018 races, a committee official told CNN hours before polls closed.

The late announcement tracks with what the party did during races in Alabama and Pennsylvania. Not looking to nationalize the race, the party will spend money quietly in a contest and then announce its efforts shortly before polls close.

Trump's first comment on the race came in early April through a Republican National Committee robocall to persuadable voters.

"Nancy Pelosi wants to send a liberal Democrat to Congress to represent you. We can't have that," Trump says in the call, a recording of which was obtained by CNN, that went out to voters on April 6. "If that happens, illegal immigrants will pour right over your border, bringing their drugs and their crime with them, right into your neighborhood, right into your back yard."

The call touted Lesko as a Republican in line with Trump on immigration and urged voters to get out and vote for her early.