Virginia Democrat Dan Helmer got a boost in his bid to unseat Del. Tim Hugo when presidential candidate Beto O’Rourke appeared by his side over the Labor Day weekend to whip up voter enthusiasm in a pivotal state election this November.

O’Rourke traveled throughout the state over the weekend, driving home the message that national Democrats want to flip control of the Virginia legislature in part to build momentum for the race for the White House.

“As important as 2020 is, the road to get there runs through 2019,” O’Rourke said at a rally Saturday in Fairfax County.

O’Rourke also campaigned with Del. Chris L. Hurst (D-Montgomery), who is defending his southwestern Virginia seat against Republican Forrest Hite, and Democrat Amy Laufer in her bid to unseat state Sen. Bryce E. Reeves (R-Spotsylvania) in a district that runs between Charlottesville and Fredericksburg.

All 140 state General Assembly seats are on the ballot in November. Republicans hold a three-seat edge in the House (51 to 48) and a bare majority in the Senate (20 to 19), with one vacant seat in each chamber. While four states will hold elections this fall, Virginia is the only one where control of the state legislature is at stake.

Hugo, who is seeking an eighth term, is the sole Republican state delegate remaining in increasingly blue Northern Virginia. His purple district straddles Fairfax and Prince William counties.

He has outraised Helmer by a nearly 2-to-1 margin, with nearly $800,000, a sizable bulk of which has come from the state GOP leadership, according to the nonprofit Virginia Public Access Project.

The party’s CommonSense VA political action committee has contributed $80,500 to Hugo’s campaign, while the Colonial Leadership Trust PAC controlled by House Speaker Kirk Cox (R-Colonial Heights) has donated $20,000. Hugo is chairman of the GOP House caucus.

Helmer, who has raised $432,000, has focused primarily on gun issues in the midst of a string of mass shootings this year, including an attack by a gunman who killed 12 people in Virginia Beach in May. Hugo’s district is the kind of suburban area where increasingly urgent concerns about gun violence could make the difference for voters.

O’Rourke, who has increasingly been talking about guns on the campaign trail, visited Helmer’s campaign headquarters Saturday evening, just hours after a gunman killed seven people in O’Rourke’s home state of Texas. It provided a moment of confluence between the two campaigns.

“We don’t know what the motivation is. We do not yet know the firearms that were used or how they acquired them,” O’Rourke said about the Saturday shooting. “But we do know this is f---ed up. This one is on all of us. Virginia will set the course for the United States of America.”

A former Army intelligence officer in Afghanistan, Iraq and South Korea, Helmer has repeatedly attacked Hugo over his support for expanding gun owners’ rights, taunting the Republican on social media with challenges to debate the gun issue.

On Sunday, Helmer briefly confronted Hugo at an India Independence Day festival in Bull Run, again challenging him to a debate focused on guns.

Hugo declined, saying he would prefer to engage voters during three community forums already planned for the election.

Hugo, who won his 2017 election by just 106 votes, has walked a fine line on the gun issue.

His voting record has earned the Republican an A rating from the National Rifle Association. But Hugo recently expressed support for a “red flag” bill that would remove guns from some people considered a risk to themselves or others, although advocates for stronger gun laws said the bill is relatively weak and mimics mental health laws that are already in place.

Hugo, who served in the Army Reserve during the 1990s, says his support for the bill introduced by Del. Jason S. Miyares (R-Virginia Beach) is not related to the election, noting that he has backed other measures to keep firearms away from people who are considered potentially violent.

At the Saturday rally, Helmer accused Hugo of voting against “every single piece of meaningful gun regulation” that has been introduced during his time in office.

“We are fighting for a commonwealth where you don’t feel like you need to wear the body armor I wore in Afghanistan just to go shopping at a Walmart,” Helmer said, referring to the Aug. 3 shooting in El Paso that killed 22 people.

Quentin Kidd, director of Christopher Newport University’s Wason Center for Public Policy, said any national attention to the race would probably benefit Helmer.

The Democrat has garnered support from several national organizations, including an endorsement from the gun-control group formed by former Arizona congresswoman Gabrielle Giffords, who has appeared at a fundraiser for Helmer.

“When you’ve got a presidential candidate walking the streets for you, that tends to get your base and your core voters excited, and that’s a good thing for Dan Helmer,” Kidd said. “Tim Hugo needs to be able to do the same thing.”

Hugo’s campaign declined to allow The Washington Post to join him as he campaigned in his district but said he had been talking to voters about schools, roads and other bread-and-butter issues.

Republicans worked to use O’Rourke’s visit to rally their base.

They linked his visit to a controversy over late-term abortions in Virginia earlier this year.

State GOP leaders highlighted a comment O’Rourke made about late-term abortions while at a recent town hall event in Charleston, S.C.

In answer to a question, O’Rourke said a woman should be allowed to decide on the best course of action, referencing the Supreme Court’s 1973 Roe v. Wade decision that protects a woman’s right to an abortion.

“Only she knows what she knows, and I want to trust her with that,” he said.

Republicans likened those comments to a statement by Del. Kathy Tran (D-Fairfax) in January about a failed bill she sponsored that would have loosened restrictions on late-term abortions.

Tran answered “Yes” during a committee hearing about the legislation when asked whether the bill would allow for abortions during labor. She later said she misspoke, but Republicans accused her of supporting infanticide.

Republicans called on Helmer and other Democrats to rebuke O’Rourke and said they plan to highlight Tran’s comments as the campaign season heats up.

“We have recognized this as a very powerful issue and a very powerful contrast between our candidates and the Democrats,” said Garren Shipley, a spokesman for House Majority Leader Todd Gilbert (R-Shenandoah).

A spokesman for Helmer said he agrees with O’Rourke’s position on abortion.

Kristin Pradko, 36, said that voters are more likely to be moved by anger over mass shootings and the fact that Virginia Republicans abruptly ended a special legislative session on gun control, convened in July by Gov. Ralph Northam (D), without considering a single bill.

She was among about a dozen members of the Moms Demand Action gun-control advocacy group who helped Helmer’s campaign approach voters Saturday.

“The minute I said, ‘The reason I’m supporting Dan Helmer is because he supports common-sense gun reforms,’ their eyes lit up,” said Pradko, who lives in Arlington, outside Hugo’s district, and plans to continue reaching voters on Helmer’s behalf.

“If we can get some good stuff done here, it’s a really good sign for reforms nationwide,” she said.