Republican Ed Gillespie nearly defeated Mark Warner (D) in the 2014 Senate race. (J. Lawler Duggan/For The Washington Post)

Virginia Republicans won their battle with Gov. Terry McAuliffe, holding on to the state Senate on Election Day last week in the face of an all-out effort by the Democratic governor. But based on their showing in several key races in Northern Virginia, some Republicans say they may be losing the war.

Even though the party retained its strong majority in the General Assembly on Nov. 3, the party lost ground in the suburbs and exurbs of Washington, the still-growing parts of the state with the most people.

Those farther-out farmlands and small towns have traditionally helped Republicans mitigate the dense Democratic vote just outside Washington. Now, as new Asian and Hispanic residents move into that territory, what was reliably red is becoming more and more challenging for Republicans, some party leaders say.

Republicans’ ability to win these exurbs could be decisive for next year’s GOP nominee, as national party operatives have long said that the GOP must win Virginia to win the White House next year.

“It’s this steady march westward that Republicans need to be concerned about,” said Dan Scandling, a longtime aide to former congressman Frank Wolf (R). “If you keep losing little bits of Loudoun and Prince William, you cannot win in the state.”

Republicans lost two state House seats in Loudoun and Prince William counties, two of three fastest-growing counties in the state. The third is Fairfax, where they lost a supervisor seat in the once-rural western part of the county. Three Republicans lost supervisor races in Loudoun, including veterans Eugene A. Delgaudio and Scott York (who ran as an independent).

Meanwhile, two more Republican supervisors won by only a few hundred votes each. State Sen. Richard H. Black, who won by 14 percentage points in 2011, this year won by five. In one of the most hotly contested Senate races on the map, a seat held by retiring state Sen. Charles J. Colgan (D), the Democratic candidate won by eight points. Incumbent Dranesville Supervisor John W. Foust (D), targeted by Republicans and outspent, also won by eight. So did state Sen. George Barker (D-Fairfax), another Republican target outspent by his GOP rival.

Republicans did pick up one House seat that straddles Prince William and more rural Stafford counties, winning by 158 votes a race where they outspent Democrats by a 3-to-1 margin. In the Prince William portion of the district, Republican L. Mark Dudenhefer lost by 30 points.

Outspent and hit with a last-minute barrage of negative ads focused on tolls, Del. Kathleen Murphy (D) still narrowly beat Republican Craig Parisot. Her district straddles Loudoun and Fairfax, but she beat Parisot even in the Loudoun portion of the district. Jennifer Boysko, likewise, beat Republican Danny Vargas for an open seat in Loudoun and Prince William. She, too, edged out her opponent in Loudoun.

That’s also despite an unprecedented GOP effort to recruit and nominate minority candidates in the diverse area. Three of their House candidates in Northern Virginia this year were minorities, and all three lost.

There were unique factors at work that won’t apply in 2016. Infighting and scandal in Loudoun created a three-way race between York, the Republican nominee and Democratic victor Phyllis Randall.

“We would rather fight with each other and try to play those types of games than try to make a larger argument about how we can govern effectively,” said Brian Schoeneman, a former Fairfax official who lost a three-way Republican primary in Sully this year.

Republicans were heavily outspent in Black’s and Colgan’s districts, both top priorities for the governor. In 2016, funding is far more likely to be evenly matched. But Democrats can also build on the investment they made this year in data and field operations.

State GOP Chairman John Whitbeck dismisses those concerns, saying that the Election Day results reveal nothing new. The two House seats lost by Republicans were overwhelmingly Democratic, he said, as was Colgan’s Senate seat. Retirements of popular incumbents cost Republicans some territory, he argued, not any new shift in demographics.

At the same time, he said Republicans were well aware that those shifts were happening.

“Nothing about Tuesday is a wake-up call; we already know the challenges that we face,” Whitbeck said. “Nobody has said in the Republican Party that the demographics haven’t changed in Northern Virginia; nobody has said that we don’t have to change our message to minority communities and appeal to suburban women.”

Republicans point to Ed Gillespie, who nearly defeated Sen. Mark R. Warner (D) in 2014, as a sign of how the party can succeed in Northern Virginia. A Republican clerk of the court held on in Fairfax. A third Republican joined that county’s school board after campaigning against new protections for transgender students. While the attacks stemming from a plan to charge single drivers a high fee to join carpoolers on a Fairfax parkway did not succeed, Republicans point out that Democrats abandoned McAuliffe on the issue.

“They don’t care what he thinks and don’t respect his policies,” said Del. Gregory D. Habeeb (R-Salem), who led House Republicans’ campaign efforts.

“It’s no secret we’ve got to do better in Northern Virginia,” said Tucker Martin, a Republican strategist and former aide to ex-governor Robert F. McDonnell. “And we’ve shown we can.”

Gillespie edged out Warner in Loudoun but lost in Northern Virginia and in the state thanks to Arlington and Fairfax. But that same year, Republican Barbara Comstock outperformed him in Loudoun in her own race for Congress, beating her Democratic opponent there by 11 points. She won the Fairfax portion of her district by about the same margin. Democrats have yet to name a candidate to challenge her in 2016, though both sides agree that an open presidential contest is their best chance to win the swing exurban district.

“If you want to know if the demographics have changed,” look at her district, said Whitbeck. “And we believe Barbara Comstock is not only going to be reelected, she’s going to be reelected by a wide margin.”