Republican Karen Handel has won a nationally watched congressional election in Georgia, avoiding an upset that would have rocked Washington ahead of the 2018 midterm elections.

Her narrow victory Tuesday over Democrat Jon Ossoff in Georgia's 6th Congressional District allows Republicans a sigh of relief after what's being recognized as the most expensive House race in U.S history, with a price tag that may exceed $50 million.

Yet the result in a historically conservative district still offers Republicans a warning — and Democrats some encouragement — that President Donald Trump's tenuous standing will dominate the looming campaign cycle. Georgia's outcome follows similar results in Montana, Kansas and South Carolina, where Republicans won special House races by much narrower margins than they managed as recently as November.

Thank you @FoxNews "Huge win for President Trump and GOP in Georgia Congressional Special Election." — Donald J. Trump (@realDonaldTrump) June 21, 2017

Congratulations to Karen Handel on her big win in Georgia 6th. Fantastic job, we are all very proud of you! — Donald J. Trump (@realDonaldTrump) June 21, 2017

Democrats must flip 24 GOP-held seats to regain a House majority next November, but the latest losses mean party leaders and liberal groups will have to rally donors and volunteers after a tough stretch of special elections.

Handel, 55, becomes the latest in a line of Republicans who have represented the district since 1979, beginning with Newt Gingrich, who would become House speaker. Most recently, Tom Price resigned the post in February to join Trump's administration as health and human services secretary. The president himself struggled here, though, edging Democrat Hillary Clinton but falling short of a majority among an affluent, well-educated electorate that typically has given Republican nominees better than 60 percent of the vote.

"This is such an important election because of what goes on in D.C.," said Tom Greathouse, 52, a business owner who supported Handel. He added that there's been "a ton of emotion" in a district used to watching Republicans coast.

In April, Handel trailed Ossoff in the first round of voting but led all Republican candidates to qualify for a runoff. Ossoff tallied 48 percent, just shy of an outright victory.

A former Georgia secretary of state, Handel emphasized throughout the campaign that she has lived in the district for 25 years, unlike Ossoff, who grew up in the district but lives in Atlanta, a few miles south of the 6th District's southern border.

Handel also pointed to the district's pedigree throughout the campaign, urging Republicans not to let Democrats "steal" a seat that became a proxy for the national dynamics in Washington. Party organizations, independent political action committees and donors from Los Angeles to Boston sent a cascade of money into a race, filling metro Atlanta's airwaves with ads and its 6th District neighborhoods with hordes of paid canvassers.

Handel insisted for months that voters' choice had little to do with Trump, whom she rarely mentioned, despite holding a closed-door fundraiser with him earlier this spring. She pointed voters instead to her "proven conservative record" as a state and local elected official. Her protestations aside, Handel often embraced the national tenor of the race, joining a GOP chorus that lambasted Ossoff as a "dangerous liberal" who was "hand-picked" by House Democratic leader Nancy Pelosi of California. She also welcomed a parade of national GOP figures to Atlanta to help her raise money, with Vice President Mike Pence and House Speaker Paul Ryan holding fundraisers following Trump's April visit.

It was enough to help Handel raise more than $5 million, not a paltry sum in a congressional race, but barely a fifth of Ossoff's fundraising haul. The Republican campaign establishment, however, helped make up the difference. A super PAC backed by Ryan spent $7 million alone.

Besides allowing national Republicans to exhale, Handel ended a personal losing streak, including failed primary bids for governor in 2010 and the U.S. Senate in 2014.

On policy, she mostly echoes party leaders. She said she'd have voted for the House Republican health-care bill, though she sometimes misrepresented its provisions in debates with Ossoff. She touts traditional supply side economics, going so far as to say during one debate that she does "not support a living wage" — her way of explaining her opposition to a minimum-wage increase.

That wasn't enough to sway the election. But a living wage was a key driver for voters like Grant Robison, 25, a Johns Creek resident who works for National Cash Register. He voted for Jon Ossoff.

"I don't think that anybody should live in poverty, dealing with that when they're working a 40-hour week," he said.