Late counted votes from Northern Virginia put populist nationalist U.S. Senate candidate Corey Stewart over the top in the Republican primary to face incumbent Sen. Tim Kaine (D-VA).

In a direct reversal of last year’s gubernatorial primary, where Stewart lost to Republican lobbyist Ed Gillespie by fewer than 5,000 votes, the Prince William County immigration hardliner appears to have scraped out a narrow win over delegate Nick Freitas, on whom the Virginia Republican establishment had pinned their hopes of defeating Stewart.

With all precincts reporting, Stewart was ahead by more than 5,000 votes. The New York Times called the race for him. “I can tell you something,” Stewart said in his victory speech in Woodbridge, Virginia, “It’s a lot better to win by 1.4 [percent] than to lose by 1.2!”

“Virginia can choose to continue with the prosperity and the progress of America under President Trump,” Stewart put to his supporters. “Or it can choose the past with everything we know that has failed, and that’s Hillary Clinton’s running mate Tim Kaine.”

Stewart ran a campaign similar to his quest for the Virginia governor’s mansion, focusing heavily on cracking down on illegal immigration and loyalty to President Donald Trump’s “America First” agenda. On Monday, Stewart gave an interview to Breitbart News Editor in Chief Alex Marlow on Sirius XM’s Breitbart News Daily:

Stewart’s victory came after enduring a barrage of late attacks from Freitas and the Republican establishment, both in Virginia and from outside the state. Freitas attacked Stewart as a “hate monger” in an email to supporters. Despite having himself been called similar things by the left, he wrote, “If we are to continue our party’s legacy, we must reject Corey Stewart’s dog-whistling of white supremacists, anti-Semites, and racists.”

Kassy Dillon, the campus conservative activist turned journalist for Ben Shapiro’s Daily Wire, turned the race particularly nasty in its final week, publishing a piece called “WATCH: VA Senate Candidate Corey Stewart Calls Anti-Semite Paul Nehlen ‘Hero,'” seven days before the election. The article fails to explicitly mention that the video in question was taken months before Nehlen launched into a series of very public and disgustingly anti-Semitic tirades, ending his political career. The article instead implied Stewart had called him a “hero” based on those remarks and set off a firestorm of hatred towards Stewart on social media.

Sensing the window to unseat Stewart, who until then had been widely seen as the presumptive nominee, the pro-amnesty billionaire Koch brothers’ group Americans for Prosperity threw its weight behind Freitas the next day, buying a digital ad campaign to back him.

These events followed the Virginia Republican Party’s disqualification of candidate Ivan Raiklin from the ballot for insufficient signatures. According to the Stewart campaign and a lawsuit Raiklin filed, this was done deliberately to make the race less favorable to Stewart, and Raiklin was immediately urged to endorse Freitas and assist with his campaign by party officials. The Virginia Republican Party disputes these claims and, at the time, a Freitas spokeswoman told Breitbart News Stewart was “peddling conspiracy theories.”

In the end, however, the statewide coalition Stewart built in his gubernatorial race – and especially his wide margin in his home suburban county of Prince William – was enough to carry him to the GOP nomination.

While he will carry his party’s banner into November, Stewart faces an uphill battle against Tim Kaine, the incumbent senator and former governor of Virginia who served as Hillary Clinton’s running mate in 2016.