ROSWELL, Ga. — Jon Ossoff, a Democrat making his first bid for elective office, narrowly missed winning outright in a heavily conservative House district in Georgia on Wednesday, throwing a scare into Republicans in a special congressional election that was seen as an early referendum on President Trump.

Mr. Ossoff received 48.1 percent of the vote, just short of the 50 percent threshold needed to win the seat, and he will face Karen Handel, the top Republican vote-getter, in a June runoff.

A documentary filmmaker and former congressional staff member, Mr. Ossoff, 30, had hoped to avert a runoff in the Sixth District, a Republican-dominated section of the Atlanta suburbs that had been represented by Tom Price, who is now Mr. Trump’s health and human services secretary. But despite his financial advantage — Mr. Ossoff had raised $8.3 million, more than quadruple that of the next-closest candidate — and a highly energized liberal base, a majority was just out of reach in a district that has not sent a Democrat to Congress since the Carter administration.

Mr. Ossoff released a statement early Wednesday after the race was called.

“This is already a remarkable victory,” he said. “We defied the odds, shattered expectations, and now are ready to fight on and win in June.”

Mr. Ossoff’s strong showing will ensure that national Democrats continue to compete here and will increase pressure on the party to contest a special House election next month in Montana that it has so far ignored. Combined with Democrats’ better-than-expected performance in a special House election in Kansas last week, the Georgia result will be an immediate boon to Democratic groups, lifting their fund-raising and bolstering candidate recruitment efforts, while sobering Republicans who are assessing whether to run in Mr. Trump’s first midterm election. Already, Republican candidates and outside groups have had to spend over $7 million against Democrats in a series of deeply conservative districts.

Early Wednesday, Mr. Trump, who had posted a number of Twitter messages on the contest in the last few days, claimed a victory for Republicans before the race was called.

Image

Supporters of Mr. Ossoff at an event in Sandy Springs on Tuesday.CreditKevin D. Liles for The New York Times

As Mr. Ossoff faces Ms. Handel in a head-to-head race on June 20, it is unclear whether he will be able to sustain the success he enjoyed on Tuesday, in an 18-person field. Ms. Handel, who received just under 20 percent of the vote, is a former Georgia secretary of state and is viewed as an establishment-friendly Republican. While she has struggled in her two most recent campaigns, losing primaries for governor and senator, she will receive the full support of a party that dominates Georgia politics, as well as nearly unlimited resources from Washington Republicans, in the runoff.

Ms. Handel, 55, has portrayed herself as a Trump supporter, though she was less fervent in her backing for him than were the other Republican candidates in the race, who adopted Mr. Trump’s catchphrases and style in an attempt to stand out.

The intense Republican competition and liberal enthusiasm lifted Democratic hopes that they could snatch a surprise victory.

“We are certainly going for an outright win here today,” Mr. Ossoff told CNN on Tuesday before the polls closed.

Much as they did in last week’s race in Kansas, Democrats initially got their hopes up after promising early-vote returns were posted soon after polls closed. But as the Election Day results trickled in, it became clear that those early and absentee ballots, reflecting their fired-up base, would not be sufficient to match the Republicans’ structural advantage in the district.

On Tuesday night, hundreds of Ossoff supporters crammed into a ballroom at a Crowne Plaza hotel. Cries of delight erupted as early returns flashed on big television screens. But many attendees were cautiously optimistic, with an emphasis on caution.

Janice Owens, 60, a project manager who had been knocking on doors and making calls for Mr. Ossoff, said she and others would not feel the effort was wasted if Mr. Ossoff failed to avert a runoff.

“I don’t think anybody thinks it’s for naught,” she said. “Because we’re not giving up.” If anything, the Ossoff campaign showed how Democrats had been successful, even in this Republican-friendly chunk of suburbia, in converting an enthusiastic but inchoate anti-Trump movement into a real political force.

Ms. Handel took the stage at a lightly attended victory party of her own shortly after 11 p.m. to claim her spot in the runoff — and urge Republicans to unify to stop Democrats’ effort to “steal a seat.”

Ms. Handel, battling a few bouts of feedback from a microphone, invoked the “great legacy” of a district that she noted had produced the former House Speaker Newt Gingrich, Senator Johnny Isakson and Mr. Price.

But she made no mention of Mr. Trump. Ms. Handel dismissed her opponent as a “young man” beholden to national liberals and vowed to “kick a little Ossoff.”

The contest here effectively represented the first performance review at the ballot box for Mr. Trump and the Republican Congress among the sort of upscale voters who were left without a political home last fall. Mr. Price’s former district is the most highly educated Republican-controlled district in the country. And while the president won here in Atlanta’s booming northern suburbs, he did so by just a single point four years after Mitt Romney romped to a 23-point victory.

For all of the attention lavished on the working class — Rust Belt voters who flocked to Mr. Trump’s campaign — voters who have flourished in the 21st-century economy will prove more crucial when it comes to the fight for control of Congress next year. If Democrats are to have a chance at recapturing the House, they will have to win over the dominant constituency here: suburbanites who only grudgingly cast a presidential ballot in November and have no deep affinity for either Mr. Trump or the Democrats.

None of the major Republican contenders pointedly distanced themselves from the president — they did not dare anger the partisans most likely to vote in a spring special election — but most of them did not make him central to their appeals, either.

With Republican Party officials worried that Democratic enthusiasm might be enough for Mr. Ossoff to get more than 50 percent of the vote and win the seat outright, though, Mr. Trump eventually did weigh in on the contest. He recorded a robocall delivered Monday to Republican voters in the district, warning that Mr. Ossoff would “raise your taxes, destroy your health care and flood our country with illegal immigrants.” And he posted on Twitter a series of messages similarly criticizing Mr. Ossoff while prodding Republicans to “force runoff.”

Mr. Ossoff walked a careful line when it came to Mr. Trump. He opened his bid with donor-tailored appeals to “Make Trump Furious” and continued similar targeted advertising throughout his campaign. But he also sought to cast himself as a consensus-oriented moderate focused on the district, dismissing Mr. Trump’s late intervention as so much noise from Washington.

Sensing an opportunity to deliver an early blow to Mr. Trump, and nudged ahead by an animated base hungry to register its fury, Democrats aggressively competed to win outright on Tuesday and avert a more directly partisan runoff. In addition to Mr. Ossoff’s astounding $8.3 million haul through the end of March, the House Democratic campaign arm poured money and staff into the district.

Republicans were as fractured as Democrats were unified, with political veterans such as Ms. Handel on the ballot as well as newcomers who saw an opportunity at a moment when the party seemed to be in flux.

The Republican field was divided over the failed bill to repeal the Affordable Care Act, but it treated the issue delicately in what amounted to a concession that what was once the safest stance in a Republican primary — demanding full repeal of President Barack Obama’s health care law — was not so clear-cut any longer.

In an illustration of how nationalized the race became, 95 percent of Mr. Ossoff’s fund-raising haul was from out of state, and even more was from outside the district, where the candidate himself does not reside (though he grew up there).

Republicans blistered him on this score and much else, a kitchen-sink campaign that totaled $5 million yet also stirred muttering within the party about why there had not been a more coherent approach to a district they knew would be competitive, given Mr. Trump’s weakness here. But the unrelenting Republican assault eventually paid off, raising Mr. Ossoff’s negative ratings and nudging conservative voters to show up for an unusual spring election.

Jonathan Martin reported from Roswell, and Richard Fausset from Atlanta.