Addressing supporters in Atlanta, Ms. Handel noted with pride that she had become the first Republican woman sent to Congress from Georgia, and she pledged to represent all of her constituents, including Mr. Ossoff’s supporters. But she made clear that she would work to pass major elements of the Republican agenda, including health care and tax overhauls.
“We have a lot work to do,” Ms. Handel said. “A lot of problems we need to solve.”
For Democrats, the loss was demoralizing after questionable “moral victories” in two earlier special election defeats, for House seats in conservative districts in Kansas and Montana. Mr. Ossoff appeared so close to victory that Democrats were allowing themselves to imagine a win that would spur a wave of Republican retirements, a recruitment bonanza and a Democratic fund-raising windfall heading into the 2018 midterm elections.
Addressing a crush of cameras and supporters who spilled out of a hotel ballroom, a subdued Mr. Ossoff tried to strike a hopeful note as he conceded defeat.
“This is not the outcome any of us were hoping for,” he said. “But this is the beginning of something much bigger than us.”
The margin in Georgia was ultimately larger than even some Republicans had expected, with tax-averse voters in the outer suburbs overwhelmingly siding with Ms. Handel.
Yet the Republican triumph came only after an extraordinary financial intervention by conservative groups and by the party’s leading figures, buoying Democrats’ hopes that they can still compete in the sort of wealthy, conservative-leaning districts they must pick up to recapture the House.
Both parties now confront the same question: What does such a hard-won victory in the Lululemon-and-loafers subdivisions of Dunwoody and Roswell, where Mr. Trump prevailed in November, augur for Republicans who next year will be defending an array of less conservative seats outside the South?
Even as Mr. Ossoff lost, Democrats’ spirits were somewhat lifted by the unexpectedly strong showing of their nominee in another special House election Tuesday, in South Carolina. In a heavily conservative district vacated by Mick Mulvaney — now the director of the White House Office of Management and Budget — African-Americans came out in force for a wealthy Democrat, Archie Parnell, and the Republican candidate, Ralph Norman, won by a narrower margin than Ms. Handel did in Georgia.
In the so-called jungle primary in Georgia — the initial special election on April 18 — Mr. Ossoff, one of 18 candidates on the ballot, captured just over 48 percent of the vote, an unusually strong showing for a Democrat but short of the 50 percent needed to avoid a runoff. Ms. Handel came in a distant second, with just under 20 percent, as Republicans divided their support among a number of credible conservative contenders.
But Republican leaders were optimistic that the party’s voters would rally behind Ms. Handel in a two-candidate showdown.
Questions also lingered about whether the grass-roots coalition backing Mr. Ossoff — fueled by highly motivated anti-Trump activists who were, in many cases, new to political activity and organizing — could improve on its April showing in a runoff held at the beginning of the summer vacation season, in a district where people have the means to escape to the beach.
Ms. Handel and her supporters portrayed Mr. Ossoff as far too liberal for a district that, covering somewhat different territory, was represented from 1979 to 1999 by Newt Gingrich, a Republican and former House speaker. They also criticized Mr. Ossoff for his youth and inexperience and assailed him for living outside the district, although he was raised in it.
Mr. Ossoff’s allies, for their part, paid for an advertising campaign deriding Ms. Handel, a former chairwoman of the Fulton County Board of Commissioners, as a profligate spender while in office. And Mr. Ossoff ran television ads that rehashed Ms. Handel’s resignation from the Susan G. Komen Foundation over her belief that the group, which raises money to fight breast cancer, should cut ties with Planned Parenthood.
While Mr. Ossoff’s supporters showed great passion, Republicans were presumed to have a heavy mathematical advantage in the district, which Tom Price, now Mr. Trump’s health secretary, won by 23 points in 2016. And it was unclear throughout the contest how the two campaigns would ultimately be buffeted by tempestuous events in Washington, including Mr. Trump’s handling of the investigation into Russian meddling in the presidential election, the House’s passage of an unpopular health care overhaul bill, and the attack last week on a group of Republican lawmakers by an anti-Trump liberal.
Republicans, fearing the symbolic and tangible repercussions of a loss in Georgia, spared no expense in propping up Ms. Handel’s candidacy. Mr. Trump, Vice President Mike Pence and House Speaker Paul D. Ryan all came to Atlanta to help her raise money, and conservative groups poured $12 million into the runoff, nearly all of it assailing Mr. Ossoff.
A “super PAC” aligned with Mr. Ryan, the Congressional Leadership Fund, spent more than $7 million from April to June.
Still, the $8 million gusher of liberal money that Mr. Ossoff enjoyed leading up to the April vote only intensified during the two-month approach to the runoff. He brought in another $15 million, much of it in small contributions from beyond Georgia’s borders. And national Democratic groups, persuaded that he had a strong shot at winning, rushed in with their own advertisements denouncing Ms. Handel.
Although they received enormous political and financial support from allies in Washington, the two candidates tiptoed around more polarizing national political figures. Ms. Handel rarely uttered Mr. Trump’s name of her own volition, preferring instead to highlight the district’s Republican lineage and warn that Mr. Ossoff would do Ms. Pelosi’s bidding. Only in declaring victory late Tuesday night did Ms. Handel make a point of offering “special thanks to the president of the United States of America,” a line that set off a boisterous chant of Mr. Trump’s name by the crowd.
Mr. Ossoff, for his part, sought to avoid being linked to Ms. Pelosi or labeled a liberal. He assured voters he would not raise taxes on the rich. And in pledging to root out wasteful spending and seek compromise, he sounded more like an heir to former Senator Sam Nunn’s brand of Southern centrism than a progressive millennial who cut his teeth working for Representative Hank Johnson, a DeKalb County liberal.
Voter turnout in April was already high for a spring special election, and it soared during the runoff, to more than 240,000, from more than 190,000. Nearly 150,000 voters cast ballots before the polls opened on Tuesday, nearly three times the early vote in the first round. And nearly 40,000 of those people had not voted at all in April.
By Tuesday, the fatigue among voters was palpable.
Some residents posted warnings demanding that campaign workers stop knocking on their doors.
“NO SOLICITATION!!!!!!!” read one sign, photographed and published on social media by a Handel supporter. “And no! We aren’t voting for OSSOFF! I have big dogs!!!”
The campaign so enveloped the Atlanta region that polling places in a neighboring district posted signs telling residents that they were not eligible to vote.