Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — Democrat Conor Lamb is the apparent winner over Republican Rick Saccone in Tuesday's special election in Pennsylvania’s 18th Congressional District, according to an NBC News projection.

With 99 percent of the votes counted, Lamb was leading by 641 votes in a district long held by the GOP and one that President Donald Trump — who backed Saccone — carried by 20 points in 2016.

Lamb declared victory early Wednesday morning. Saccone has not conceded and his campaign is in touch with legal counsel.

Shortly before 1 a.m., Lamb was introduced as "congressman-elect" at his election night party.

"It took a little longer than we thought, but we did it!" Lamb told cheering supporters.

Lamb, 33, was already looking ahead to Capitol Hill, saying, "Our job in Congress is to attack the problems, not each other."

In an appearance on MSNBC's "Morning Joe" on Wednesday, Lamb said his apparent win was the result of "good old-fashioned hard work" and a grass-roots campaign that spoke directly to voters in his district about their concerns.

"We didn't take a single vote or a single town or inch of ground for granted," he said.

Lamb also reiterated his position on the leadership of both parties, saying Minority Leader Nancy Pelosi, D-Calif., and House Speaker Paul Ryan, R-Wis., should step aside.

"I would like to see someone other than Nancy Pelosi run — and that person I would support — and I would definitely like to see a different leader other than Paul Ryan on the other side," he said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"It's nothing personal. I just think the leadership of both parties has presided over a time when we've had more and more gridlock and fewer and fewer important things getting done, and I always learned that leadership starts at the top," he said.

Lamb also expressed a willingness to work with Trump, saying there are some issues, such as infrastructure, on which he agrees with the president.

"Regardless of who the president is or which party is in control of the White House, it's time for us to get some bills passed," he said.

Saccone, 60, addressed his supporters on Tuesday night but stopped short of any declarations.

"We're not giving up," Saccone said at about 11:30 p.m. "We're going to be working late into the night, tomorrow. ... Don't give up! We're going to win it!"

Under state law, supporters of either candidate can request a recount if they believe there was an error in the initial tally. There is no provision, however, for automatic recounts in tight congressional elections.

Bob Branstetter, general consultant for the Saccone campaign, told NBC News that the campaign has been in touch with legal counsel and is exploring all its options.

The little-known third party Libertarian candidate had over 1,300 votes, more than the margin separating the two major candidates.

The race is being closely watched as a pulse check on Trump's political health ahead of November's crucial midterm elections.

But the contest was never supposed to be competitive. In fact, there are 114 Republican-held House seats more competitive than Pennsylvania's 18th, according to a Democratic tabulation of the Cook Political Report's partisan voting index.

The race flew under the radar for months because no one — most of all Democrats — thought they had a chance. The western Pennsylvania district is in the heart of "Trump country," as the president himself dubbed it Saturday during a campaign appearance for Saccone, and it voted overwhelmingly Republican in the past three presidential elections.

Conor Lamb speaks to supporters at an election night rally in Canonsburg, Pennsylvania, early Wednesday. Drew Angerer / Getty Images

The district was gerrymandered to guarantee easy re-elections to its former occupant, Tim Murphy, an anti-abortion Republican who was forced to resign last year after it was revealed that he had pressured his mistress to have an abortion.

But Lamb, propelled by the national anti-Trump tailwind, had steadily gained in recent polls.

Republicans sounded the alarm as early as January and began dumping millions of dollars into the race to boost Saccone.

With two visits to the district, Trump led a parade of high-profile surrogates for Saccone, underscoring both how invested the White House and GOP leaders were in the race, and how nervous they were about its outcome.

National Democrats, on the other hand, kept their distance. Determined not to repeat the fiasco of last year's special election in Georgia, when their multimillion-dollar intervention ended up tainting the party's candidate in the eyes of conservative voters, they gave Lamb room to define himself.

Rick Saccone speaks to supporters on Tuesday. Jeff Swensen / Getty Images

Drawing on his background as a Marine and former federal prosecutor, Lamb disowned Pelosi and staked out positions on abortion, guns and fracking that hewed closer to the GOP.

But Lamb also embraced the classics of the Democratic playbook, hammering Saccone for allegedly wanting to cut Social Security and Medicare, and uniting Pittsburgh's powerful unions behind him in a way no Democrat had before in that district.

While the district will soon no longer exist, thanks to a recent ruling by the Pennsylvania Supreme Court, and one House seat is not worth much in 2018 Washington, the race was nonetheless freighted with real consequences for both parties as they gear up for the midterm elections.