Virginia Republicans turned bright red Tuesday, selecting the more-Trump-than-Trump Corey Stewart as their nominee to challenge Sen. Tim Kaine (D) as primary elections played out in congressional districts across the state.

The matchup ensures Virginia will keep re-litigating the 2016 presidential race in this fall’s election, with Stewart running in outrageous Trump-like fashion against Kaine, who was Hillary Clinton’s running mate in her failed bid for the presidency.

Trump acknowledged Stewart’s victory Wednesday morning, tweeting shortly before 6 a.m.: “Congratulations to Corey Stewart for his great victory for Senator from Virginia. Now he runs against a total stiff, Tim Kaine, who is weak on crime and borders, and wants to raise your taxes through the roof. Don’t underestimate Corey, a major chance of winning!”

Republican voters in Virginia chose Stewart, who has promised a “vicious” campaign, over a more mainstream option in Del. Nick Freitas (R-Culpeper), a former Green Beret who had little name recognition but support from the party establishment.

Freitas posted a surprisingly strong challenge, with the lead tipping back and forth until the final precincts reported at nearly 9 p.m. and populous Fairfax County put Stewart over the top. Stewart prevailed with about 45 percent of the vote to about 43 percent for Freitas.

“I was on the knife’s edge of the greatest moment of my political career and the end of my political career,” Stewart said after the votes were counted. “If I didn’t win this, I would’ve been done.”

Stewart’s presence atop the ticket will cast a shadow over all Virginia congressional races this year. He’s sure to excite the most fervent parts of the Republican base, especially in rural areas, but his identification with Trump also could inspire Democratic voters to come out against him.

At Stewart’s election night party at the Electric Palm Restaurant, overlooking the Occoquan River in Woodbridge, supporters yelled “Corey! Corey!” as the loudspeaker blared “Sweet Home Alabama.”

Stewart was quick to make clear that he plans to run this race in the manner and style of his political hero, down to his hand gestures. “Virginia can choose to continue with the prosperity and the progress of America under President Trump,” he said, “or it can choose the past, with everything we know that has failed — and that’s Hillary Clinton’s running mate, Tim Kaine.”

Which prompted the crowd to erupt in chants of “Lock her up!” Stewart smiled slyly, then replied: “That might just happen, by the way. And Timmy, too. Oh, we’re gonna have a lot of fun between now and November, folks.”

Stewart railed against “criminal illegal aliens,” adding, “by the way, they are animals.” He said that Virginia can choose to let them overrun the state, or “we can arrest them, deport them back to the country they came from and build the wall.” That triggered a familiar response from the crowd: “Build the wall! Build the wall! Build the wall!”

Virginia primary election results 2018: Senate and House races

Though Stewart tends to attract attention, Virginia will also host one of this year’s most closely watched congressional races. State Sen. Jennifer Wexton beat five other Democrats in the 10th District to take on U.S. Rep. Barbara Comstock, a Republican incumbent seen as vulnerable in the Democratic quest to take back control of the House of Representatives. Virginia is among a handful of states where Democrats hope to make gains.

Democrats also chose Elaine Luria to face Rep. Scott W. Taylor in the 2nd District in Hampton Roads and Abigail A. Spanberger to challenge Rep. Dave Brat in the 7th District outside Richmond. In a year when female candidates are running in record numbers, that means Democrats will run three women to challenge vulnerable Republican incumbents in Virginia.

“I just feel like rallying that blue wave, getting as much grass-roots base-type support” as possible, said Democratic voter Jeanine Callahan, 59, from Oak Hill. Trump’s victory spurred her to get involved in politics, she said. “I think we need to match the sentiment that he was able to rally.”

Any Republican faces an uphill climb statewide in Virginia, the only Southern state that Trump lost two years ago.

Voter turnout Tuesday was generally low despite most of the state enjoying mild spring weather. Some in the Washington region may have been distracted by the Capitals’ midday Stanley Cup parade, but it didn’t stop Democrats from showing up at the polls in greater numbers than Republicans in many locations.

Stewart received about 136,000 votes in Tuesday’s primary, about 20,000 less than his total in last year’s gubernatorial primary.

Kaine, a popular former governor, is heavily favored to win in November and has more than $10.5 million cash on hand. None of the three Republicans chasing the nomination cracked $1 million; Stewart raised the most, with about $841,000.

“I know Corey very well,” Kaine said Tuesday night as he attended Wexton’s victory party in Sterling. He said Virginians will have to decide whether they support Stewart’s “ruthless ambition” or want “upbeat, progressive problem-solving.”

Stewart, Kaine added, also supports “calling people names, taking health care away from folks and cutting education.”

Democrats made big gains in Virginia elections last year, wiping out a 2-to-1 Republican advantage in the House of Delegates. Those gains led the closely divided Virginia legislature to vote to expand Medicaid this year under the Affordable Care Act, something the Republican majorities in the General Assembly had resisted for four straight years.

One issue that resisted cross-party compromise, though, was guns — and that topic seemed high on the minds of voters at polling places across the state Tuesday.

“We need to make common-sense [gun-control] legislation,” said Deborah Mangano, 55, a voter in Prince William. “We need to get people in who believe the same way and aren’t backed by” the National Rifle Association.

Perhaps the only topic that seemed more polarizing among voters interviewed Tuesday was Trump, who has low overall approval in Virginia but inspires fierce loyalty among a subset of Republicans.

Virginia Republicans have struggled with the Trump factor. Ed Gillespie nearly lost the gubernatorial nomination to Stewart, who rallied the pro-Trump base, and then walked a tightrope, uncertain how much to align himself with Trump. In the end, he lost the governor’s race by nine points.

Other big-name Republicans stayed out of this year’s U.S. Senate race, and party leaders fretted over the likelihood that Stewart would get the nomination.

Former Republican Lt. Gov. Bill Bolling tweeted Tuesday night: “I am extremely disappointed that a candidate like Corey Stewart could win the Republican nomination for U.S. Senate. This is clearly not the Republican Party I once knew, loved and proudly served. Every time I think things can’t get worse they do, and there is no end in sight.”

But Republicans haven’t won a statewide race in Virginia since 2009, and after last year’s drubbing, there was little appetite to take on Kaine in the current environment.

While Stewart most closely resembles Trump in his bombastic style, all three GOP candidates supported the president. Freitas, a second-term legislator, is far less well known but drew national attention this year for a fiery speech that linked school shootings to the “abortion industry.”

The speech motivated voter Greg Barnekoff, 33, to vote for Freitas in Prince William County. “A friend on Facebook posted the video again, and I was like: ‘Oh, that’s right. I want to vote for that guy,’ ” Barnekoff said.

Freitas won endorsements from the Koch-backed Americans for Prosperity; the NRA; Sen. Rand Paul (R-Ky.) and his father, former congressman Ron Paul; and Sen. Mike Lee (R-Utah). America’s Liberty PAC, aligned with Rand Paul, spent $225,000 on a TV buy for Freitas last week.

Tuesday night, after the race was called, Freitas appeared before supporters at McMahon’s Irish Pub in Warrenton. He urged the crowd to support Republicans in the fall and named other candidates but did not mention Stewart.

The third Republican candidate, E.W. Jackson, is a Harvard Law School graduate and minister from Chesapeake who ran unsuccessfully for U.S. Senate in 2012 and then ran a failing bid as the GOP nominee for lieutenant governor in 2013.

This race is the third — and most successful — statewide bid for Stewart, the chairman of the Prince William Board of County Supervisors. In addition to losing the GOP nod for governor last year, he also unsuccessfully ran for his party’s nomination for lieutenant governor in 2013.

Stewart gained a statewide following after his strong showing last year but also attracted notoriety after associating with white supremacists.

Carol Czarkowski, a retiree from Gainesville who came to his victory party, said Stewart’s victory made her feel vindicated after she and other campaign volunteers endured months of angry insults, including being called racists.

“I had people calling Corey names today, just because he supports our history,” she said, referring to Stewart’s fight to preserve Confederate monuments, which is what drew her to him.

Some voters expressed disgust with Stewart’s Trumpian antics, which in the past year included raffling off an assault rifle and holding up a roll of toilet paper outside the state Capitol to rail against those he called “flaccid” Republicans who voted to expand Medicaid.

Tom Stiehm, 48, a Prince William County voter, cast a ballot for Jackson as a protest. Jackson “wasn’t the other two, particularly Corey Stewart,” he said, calling Stewart “a horrible human being.”

Others said the behavior of Trump and Stewart was why they wouldn’t vote for any Republican.

“I want them all out,” said Cheryl Washington, 63, a technology contractor in Fox Mill.

Jenna Portnoy, Rachel Weiner, Antonio Olivo, Laura Vozzella, Rachel Chason, Justine Coleman, Miela Fetaw, Casey Smith and Amy Zahn contributed to this report.