Democratic gubernatorial candidate Tom Perriello, left, and rival Lt. Gov. Ralph Northam face off Tuesday in a tight primary race. (LEFT: Evelyn Hockstein for The Washington Post; RIGHT: Bill O’Leary/The Washington Post)

Outspent on the airwaves in the final days of Virginia’s gubernatorial primary, Democrat Tom Perriello scrounged for votes in the dead of night Saturday at a truck stop and a Waffle House in rural parts of the state.

A few hours later, his rival, Lt. Gov. Ralph Northam, showcased the power of the state’s Democratic machine at his disposal as he campaigned in voter-rich Northern Virginia with three power hitters beloved by state Democrats: Gov. Terry McAuliffe and the commonwealth’s two U.S. senators, Tim Kaine and Mark R. Warner.

Meanwhile, Ed Gillespie, the front-runner in the Republican contest, who has enjoyed a hefty lead in polls and campaign cash over his two GOP competitors, seemed to campaign over the weekend as if he had already advanced to the general election, touring Democratic-leaning parts of Richmond and Fairfax County.

Virginia’s gubernatorial race — one of just two in the country this year and the first statewide contest in a swing state in the Trump era — enters a new phase Tuesday as voters head to the ballot box to choose both party’s nominees. The final days of the primary cycle are ending on familiar notes.

Meet the candidates running to become Virginia’s next governor

On the Democratic side, Northam has kept rallying the party faithful, while Perriello has tried to tap into anti-Trump ­energy and economic populism to create a surge of new primary voters.

In the GOP race, Corey Stewart, chairman of the Prince William Board of County Supervisors, and state Sen. Frank W. Wagner (Virginia Beach) are trying to close Gillespie’s enormous lead.

Stewart, who has relied on ­attention-grabbing tactics in lieu of significant campaign cash or endorsements, stoked new controversies over the weekend.

The candidate held aloft a bag of Tyson Foods chicken nuggets at a Fredericksburg diner as he pilloried Gillespie for his lobbying firm’s assistance to the company when it was accused of smuggling immigrant workers. He recorded a Facebook Live video in front of a Stonewall Jackson statue in Manassas, his latest defense of monuments to Virginia’s Confederate heritage. And his campaign feuded with a local television station that initially refused to air a campaign ad featuring a controversial image of comedian Kathy Griffin holding up a likeness of President Trump’s bloody, severed head.

Wagner, a 25-year lawmaker, wrapped up his low-key, policy-driven campaign with stops in southwest Virginia and a continued focus on transportation and technical-education issues.

While the two Democratic contenders were tied in the most recent public polling a month ago, Northam has since outspent Perriello, a former one-term congressman and diplomat in President Barack Obama’s administration, on campaign commercials and had nearly twice as much cash heading into the final two-week stretch.

Perriello sought to overcome this advantage by barnstorming Virginia over the weekend, beginning with a blitz of 24 hours of campaigning that started at 7 a.m. Friday.

Periello on Saturday started a 24-hour campaign push with a run with supporters on the University of Virginia campus. (Norm Shafer for The Washington Post)

Just before 2:30 p.m. — and still energetic — Perriello made a pitch for voting in an off-year election to the owner of a Cajun restaurant in Petersburg.

“It’s the first big election since Trump got elected,” Perriello said. “With high turnout, they’ll see people are pissed.”

“I’m your typical presidential-only voter, and we got to a place like this because people like me let it get there,” the owner, 54-year-old David Payne, responded. “Shame on me.”

“Well, we are counting on you, trust me,” Perriello said.

“You’ll see me there,” Payne reassured the candidate. Payne later told a reporter that he was pushing all his friends who normally scoff at state-level races to turn out. “We have to take our country back.”

Twelve hours later, Perriello entered a rest stop in rural Ashland with his hair disheveled, tie removed, and voice groggy and bordering on slurring. No customers to be found at 2:15 a.m., he introduced himself to the clerk staffing the convenience store.

“How’s your job?” he asked.

“I make $9.66 an hour after working for years,” Candace Niles, 27, said with a sigh. “I’m a single mom with three kids.”

“Would it change your life much if minimum wage was $15 an hour?” Perriello asked, referencing a policy he and Northam support but Republicans in the legislature oppose.

“Fifteen dollars, that would be amazing,” Niles said. “This job sucks.”

Niles said she doesn’t pay much attention to politics and probably hasn’t voted in state races, but she backed Trump in November because he seemed to have her interests at heart. Even though Perriello is an outspoken Trump critic (and he didn’t mention the president or his Democratic affiliation), Niles said he won her vote just by suggesting policies that could help.

Perriello had no such luck with another employee.

“I stay out of politics,” said Delores Lee, a 46-year-old Richmond resident who thinks it’s impossible for state politicians to get anything substantive done.

In an interview, Perriello said he’d be the stronger candidate to take on the Republican in the fall. And he believed months of meeting voters around the state would pay dividends Tuesday, even though Northam has financial and endorsement advantages.

“The groups we are surging with — young voters, voters of color and rural voters — are groups that don’t normally vote for Democrats in a state election,” Perriello said over a 4:45 a.m. breakfast at a Waynesboro Waffle House where a dozen anti-gas pipeline activists came out to meet him. “People really appreciate we have been willing to go out and do dozens of town hall meetings and literally hundreds of public events this year.”

As Perriello continued to campaign through the state, Northam spent the last days before the primary with Virginia’s Democratic all-stars in Northern Virginia, Richmond and Hampton Roads — the densely populated “urban crescent” areas that will probably decide the primary.

Wearing a crisp blue button-down shirt and neat khakis on a sunny Saturday morning, a relaxed Northam seemed content to let his high-octane backers rev up a crowd of 60 volunteers in an Old Town Alexandria courtyard for him.

“I’ll tell you about this guy,” said Kaine, dropping his hand onto Northam’s shoulder. “He appears pretty mellow, but do not tussle with him on a matter of principle. . . . You are not going to budge him one centimeter.”

Kaine, Warner and McAuliffe all touted reasons Northam would be the party’s best ­standard-bearer in a nationally watched race: his Army background in a state with deep military ties, his experience as a doctor at a time when health care is a pressing issue, and the ways his years in Richmond will help him get things accomplished.

One of the volunteers listening was Billie Schaeffer, an Alexandria actress drawn to Northam’s experience in Richmond as a state senator and lieutenant governor.

“We know we can trust him because we’ve trusted him for years,” she said, rejecting the idea that his establishment support somehow makes him tainted. “You might call it establishment; I call it educated. They’re fighting the good fight for the right reasons.”

At a canvass staging center in the Arlington neighborhood of Columbia Pike, McAuliffe seemed to take a swing at Perriello’s outsider challenge and the notion that Virginia needs a new breed of progressives to shake up the establishment.

“This is about our future! This is about Virginia! Forget Washington — this is about governance, good governance,” said McAuliffe, who is prevented by the state constitution from seeking a second consecutive term.

Then, McAuliffe linked hands with Kaine, Warner and Northam, and they raised them high — three men who had held the governor’s office with a fourth looking to join them.

Waiting in line for canvassing materials with his wife, Sean McDaniel said he resented the idea that national figures backing Perriello, including Sens. Elizabeth Warren (D-Mass.) and Bernie Sanders (I-Vt.), act like they know better than Virginians what’s good for the state.

“Ralph is a better fit for Virginia,” said McDaniel, 35. “I’m kind of irritated that people who we like and admire are getting rolled over by some national politics and outside funding.”

Gillespie declined to weigh in on the heated Democratic race as he left a brief stop Wednesday at a coffee shop in deep-blue Arlington, where he told a pair of customers that he was running a campaign “focused on small businesses and job creation.”

He carried that message as he campaigned across Northern Virginia and Richmond.

“I care a lot about the future of Virginia,” Gillespie told a crowd Saturday at a Taste of India festival in the Richmond suburb of Chester, after wolfing down a plate of what appeared to be chicken tikka masala. “That’s why I’m running. I’m worried about our future. We need more economic opportunity.”