RICHMOND — GayDonna Vandergriff has spent much of the year running for the House of Delegates with Hillary-blue campaign signs and a website that touts public schools and the environment but makes no mention that she’s a Republican.

But days before Tuesday’s state election, Vandergriff is executing a hard right turn toward her GOP base. She is blasting her opponent, Democratic incumbent Del. Schuyler T. VanValkenburg, as a “socialist” who wants to abort babies at the moment of birth and “chooses illegal immigrants over his own constituents.”

In crucial swing districts, from Northern Virginia to Richmond to Hampton Roads, Republican candidates are trying to turn out GOP voters while hoping they can hang on to the centrist images they cultivated all summer. To pull it off, they’re casting Democrats as extremists — invoking hot-button issues such as abortion and immigration that Republicans had largely avoided as they attempted to soften their connection to an unpopular President Trump.

“The strategy was to try to make it comfortable for women to vote Republican again,” longtime Virginia political analyst Robert Holsworth said. The harsh turn “may be a risky strategy because it may remind people again of their Republican identity, which at the moment is not that popular in suburban Virginia.”

Democrats, too, have resorted to tougher tactics as next week’s election looms, depicting Republicans as chummy with Trump and in the pocket of the National Rifle Association. But that’s consistent with the strategy they’ve adopted all along, in a year when national Democrats view Virginia as a tuneup for next fall’s presidential contest.

“The road to 2020 runs through 2019,” Democratic presidential hopeful Beto O’Rourke said in a video the Democratic Party of Virginia tweeted on Wednesday. “And the success for the United States of America is dependent on what we do this year in the commonwealth of Virginia.”

With all 140 seats in the General Assembly on the ballot next week, control of the legislature is at stake. Republicans are defending slight majorities of 20-19 in the Senate and 51-48 in the House of Delegates, with one vacancy in each chamber.

If Democrats can win both, they’ll consolidate power with Gov. Ralph Northam and be able to push through an ambitious agenda of gun control, abortion access, environmental protections, a higher minimum wage and passage of the Equal Rights Amendment. They’ll also oversee redistricting in 2021 after the U.S. Census, setting the course for Virginia politics for the next decade.

Many of the Democratic issues poll well with Virginians, particularly in the suburbs — which is why Republican candidates treated them carefully for much of the summer. A number of GOP incumbents have touted their support for Medicaid expansion even though they opposed it for years until a few joined with Democrats to pass it in 2018.

Sen. Glen H. Sturtevant (R-Richmond), considered one of the most vulnerable incumbents because his district has become increasingly blue, initially focused on health care in a campaign that could have been mistaken for a Democrat’s.

“Health care shouldn’t be a partisan issue,” he says in an ad launched in mid-September. “My mom suffered a near heart attack. Then her insurance surprised her with a bill they refused to pay. I’m taking on the insurance companies to stop surprise billing.”

But Sturtevant, who has spent nearly $1 million on TV ads, has recently lobbed sharp attacks at his Democratic challenger, Ghazala Hashmi. “Hashmi’s radical politics are just like Alexandria Ocasio-Cortez,” one ad says, referring to the liberal first-term New York congresswoman.

Another ad pairs Hashmi’s image with those of Ocasio-Cortez and Sen. Bernie Sanders, the Vermont Democratic Socialist running for president. “Ghazala Hashmi wants to bring Washington’s extreme socialist agenda to Virginia,” it says.

Hashmi has spent $812,000 on ads, beginning with upbeat biographical spots but turning more recently to attacks on Sturtevant’s record and “slick image campaign.”

“Sturtevant voted to deny health coverage to 400,000 Virginians,” one ad says, referring to his opposition to expanding Medicaid. Another ad shows newspaper headlines on mass shootings, including one that reads, “Massacre on campus.”

“If you ever wonder why this keeps happening, it’s because Republican politicians like Glen Sturtevant block laws that would save lives,” the ad says. Another ad highlights Sturtevant’s A rating from the NRA. A YouTube spot calls his tactics “a page right out of Donald Trump’s playbook.”

Republican Sen. Siobhan S. Dunnavant (Henrico) is another incumbent in a rapidly shifting district who played down her party affiliation during much of the campaign. Early on, Dunnavant, an OB/GYN with an A rating from the NRA, released an ad that cast her as a doctor and mother concerned about gun violence.

But in the final weeks, Dunnavant is focused on abortion.

Earlier this year, Del. Kathy Tran (D-Fairfax) presented a bill to a General Assembly subcommittee that would have loosened restrictions on late-term abortions. Tran’s testimony that the bill would allow abortion up to the point of delivery — something Virginia law already allows in certain circumstances — drew national outrage from conservatives and figured to be a prominent talking point for Republican campaigns.

After Alabama and several other states sought drastic abortion restrictions this summer, though, Virginia Republicans backed off the issue, fearing that voters would see it as a broader attack on abortion rights.

Dunnavant has cast that caution aside. Her recent ad uses video in which Dunnavant’s opponent — Del. Debra H. Rodman of Henrico — is standing next to Tran during the controversial testimony.

Rodman’s role as a co-sponsor of Tran’s bill “kind of makes it hard to resist,” said a Republican strategist familiar with Dunnavant’s campaign, who spoke on the condition of anonymity to discuss strategy. “Independents, when they see that video, they’re turned off. . . . We thought it would be important to put in front of voters as part the closing message. And we think it’s working.”

Rodman’s campaign has countered with mailers saying Dunnavant wants an “extreme ban” on abortion, based on recorded comments in which Dunnavant says she would like to ban abortion after 12 weeks unless the mother’s life is at risk.

Rodman is also airing a TV ad that features another Henrico County OB/GYN accusing Dunnavant of undermining the Affordable Care Act with a bill that would have expanded low-cost, short-term plans that do not cover preexisting conditions.

“The truth is, Senator Dunnavant’s 96% Republican party-line voting record to block Medicaid Expansion and gun safety legislation is completely out of line with what our community cares about,” Rodman said in an email.

In Virginia Beach, Republican challenger Shannon Kane sent a mailer in which an image of Democratic Del. Kelly K. Convirs-Fowler had been photoshopped into a picture of MS-13 gang members, provoking cries of racism like those that greeted a similar tactic by GOP gubernatorial nominee Ed Gillespie in 2017.

Also in Virginia Beach, the husband of a victim of that city’s May 31 mass shooting complained that his words were used without his permission in a mailer for incumbent Sen. William R. DeSteph Jr. (R). DeSteph said he had no control over the mailer, which — in an unusual move — was funded by the Republican Party of Virginia but not coordinated with the candidate.

In Richmond, Democrat VanValkenburg has faced relentless attacks as he defends the seat he flipped to blue from red two years ago. His own words are being thrown back at him: In 2016, before he held office, VanValkenburg defended U.S. Sen. Tim Kaine (D) against criticism from the left. Writing on Facebook that “I identify as socialist in many ways,” he slammed socialists for judging Kaine as not progressive enough.

His reelection opponent, Vandergriff, has taken the comments literally and depicted him in a Soviet-style poster, continually referring to him as a socialist. VanValkenburg, a high school government teacher, dismisses the attacks as “such a caricature of that kind of Trump style.”

But they have drawn notice. Constituent Jim Schroering stopped his truck on Sunday afternoon when he saw VanValkenburg canvassing his neighborhood. “I can’t believe what I just got in the mail,” Schroering, 61, said, then described one of Vandergriff’s mailers.

“I was so disgusted by looking at it,” Schroering said. He said that he had seen Vandergriff’s campaign signs earlier and hadn’t been able to figure out her party affiliation, but that the attack ads cleared up the mystery. “That’s got to be a Republican,” he said.

Vandergriff’s campaign did not respond to requests for comment. But a spokesman for the State Government Leadership Foundation (SGLF) — a partner of the Republican State Leadership Committee, which focuses on winning state-level elections for Republicans — defended the tactic.

“Schuyler VanValkenburg labeled himself a socialist on his personal Facebook page,” SGLF spokesman David Abrams said via email. “Our issue ad is simply sharing his own words, along with his record of support for the dangerous policies of radical liberals like Bernie Sanders and Elizabeth Warren. Questions about VanValkenburg’s socialist views should be directed to VanValkenburg.”