Virginia Sen. John S. Edwards (D-Roanoke) listens in the group during a roundtable talk with Virginia Gov. Terry McAuliffe (D) earlier this month. (Heather Rousseau/AP)

In a state Senate race here in the Blue Ridge Mountains, a veteran Democrat is trying to fend off two challengers for one of the last patches of blue in rural Virginia.

The race, for the seat Sen. John S. Edwards (D-Roanoke) has occupied since 1996, could determine which party controls the Senate and whether Gov. Terry McAuliffe (D) has sway with the legislature in the remaining two years of his term. It also will show whether Democrats in this key presidential swing state can maintain a foothold in the region.

Even some Democrats who think Edwards is safe say the district has grown more challenging.

“In the far end of the county, you can’t find a Democrat with a search warrant,” said David “Mudcat” Saunders, a Democratic strategist who helped Mark Warner woo rural voters in the 2001 race for governor — and saw him get clobbered in the Southwest in his nail-biter reelection to the U.S. Senate last year.

Republicans are trying to knock off Edwards, a former Marine and U.S. attorney for the Western District of Virginia, with Nancy Dye, a businesswoman, civic leader and retired surgeon. Edwards also faces a challenge from Roanoke Commonwealth’s Attorney Don Caldwell, a longtime Democrat running as an independent.

Dye has run an energetic campaign, pulling in about the same amount of campaign cash, about $290,000, as Edwards since last year. Caldwell lags far behind, raising $50,000, according to the nonpartisan Virginia Public Access Project. His bid is widely considered a long shot, but he could play the role of spoiler in a tight race.

All 140 legislative seats are up for grabs in November, but with the House of Delegates firmly in Republican control, most of the attention is on the Senate, where Republicans enjoy a 21-19 majority. Democrats have to hold onto all of their seats and pick up one more to make it a tie and take control. Democrats would be in charge of a 20-20 Senate, because Lt. Gov. Ralph Northam (D) presides over the chamber and has the power to break most ties.

With most Senate incumbents considered safe, all eyes are on a handful of open or hotly contested races, Edwards’s among them.

When Edwards won his first race for Senate 20 years ago, great swaths of rural Virginia were represented by fellow Democrats. Four of the six senators elected to represent the Southwest that year were on his side of the aisle. Today, Edwards is the only senator from the Southwest with a “D” by his name. He is one of just two west of Charlottesville, the other being Sen. Creigh Deeds (D-Bath).

Edwards’s district takes in parts of the Roanoke Valley and Southwest Virginia, regions that formed the backbone of the old Virginia economy and were crushed in recent decades by the collapse of local tobacco, furniture-making and textile industries.

Each of the three candidates promised to boost the region’s economy and political clout last week, when they appeared at a forum in downtown Roanoke. All gun rights supporters, they spoke on broad themes without drawing sharp policy distinctions. Edwards mentioned his support for expanding Medicaid under the Affordable Care Act, however, while Dye said she was opposed to “federal overreach.”

Edwards touted his long tenure in Richmond. “When I come back to Richmond, I will be number seven in seniority,” he said. “That will give us an opportunity to have more clout and put Southwest Virginia in the driver’s seat.”

Dye highlighted her experience outside of politics.

“Consider sending someone to Richmond who isn’t a professional politician, whose only loyalty will be to you, someone whose real-life experiences as a doctor, businesswoman, a wife and mom have prepared me to represent you and your families,” she said.

Caldwell said he would have leverage as an independent in a closely divided Senate, parlaying his crucial swing vote into gains for the region.

“If we could put an independent in the Senate in 2016, you would have somebody who would be sought out for a change,” he said. “You would have a place at the table.”

The 21st Senate District was drawn with a pronounced hook, which makes it resemble an inverted Cape Cod and allows it to take in the deep-blue city of Roanoke and the area around Virginia Tech. Thanks to the city and Tech votes, the district has remained reliably Democratic even as other parts of it have grown redder like the rest of Southwest Virginia.

When Warner narrowly won reelection to the U.S. Senate last year, it was no thanks to most of the Southwest, which rejected the former governor by double-digit margins. But 54 percent of Edwards’s district went for Warner over Republican Ed Gillespie. That’s down, however, from the 70 percent margin Warner won in the district in his first race for Senate in 2008, when he beat former governor James S. Gilmore III (R) in a landslide.

Democrats have been losing support in the rural South since the 1960s, but what had been a long, slow slide seemed to reach a tipping point around 2010, leaving the party with little or no sway in those regions, said Virginia Tech political science assistant professor Jason P. Kelly. He noted that Democrat Rick Boucher, who had represented Southwest Virginia in Congress since 1983, lost his seat that year to Morgan Griffith (R).

“We had seen Democrats remain at least relevant in the South and Southwest Virginia, and that seems to be less the case now,” Kelly said. “The blue dog Democrat that used to do well does not anymore.”

Kelly and a colleague, D. Xavier Medina Vidal, are studying why Democrats in Southwest Virginia, West Virginia and parts of Kentucky have been doing worse, even as President Obama’s performance in those areas held relatively steady between 2008 and 2012. The trend coincides with the rise of the tea party, but Kelly said they had not yet delved into what is driving it.

Edwards’s district picked McAuliffe for governor in 2013, sent Obama back to the White House in 2012 and, also that year, put former governor Tim Kaine (D) in the U.S. Senate. Edwards easily won his most recent election, in 2011, beating well-funded Republican Dave Nutter with 56 percent of the vote.

Senate Minority Leader Richard L. Saslaw (D-Fairfax) looks at those results and sees an easy win for Edwards.

“Obama, Kaine, McAuliffe and Warner all carried it easily — I mean easily,” he said.

But Republicans say they have a good shot with Dye, who lives in Roanoke and has long been active in city schools and local charities.

“Beating an incumbent in a grossly gerrymandered district is a difficult challenge, but Nancy has the best shot of any Republican challenger in the last 20 years,” said Thomas Cullen, a Roanoke lawyer. “We expect her to do very well in the few Republican-leaning precincts, but also to be competitive in areas where Democrats usually sweep.”