Democrats Jennifer T. Wexton, left, Abigail Spanberger, center, and Elaine Luria defeated Virginia Republicans. (Cal Cary, Ryan M. Kelly and Vicki Cronis-Nohe/for The Washington Post)

The first sign came last year. Chesterfield County, a stretch of suburban and rural communities southwest of Richmond, backed a Democrat for governor for the first time since 1961.

Since then, in Chesterfield, and in Loudoun County outside Washington, and in parts of Hampton Roads — all once reliable GOP suburbs — anger toward President Trump has been building. And on Tuesday, voters in those populous communities flipped three Republican congressional seats, electing a trio of Democratic women.

In the communities nearest Washington, where national politics are inescapable, it had long been predicted that Democrat Jennifer T. Wexton would beat Rep. Barbara Comstock, a classic establishment Republican — and she did, easily.

More telling was the razor-thin victory of Democrat Abigail Spanberger over Rep. Dave Brat in the Richmond suburbs that include Chesterfield, as well as the squeaker that Democrat Elaine Luria pulled off against Rep. Scott W. Taylor in Hampton Roads.

In Virginia and around the country, Democrats tapped into outrage from suburbanites, particularly college-educated women but also immigrants and some white men who had voted for Trump in 2016, to help them win control of the House.

“It’s the suburban transformation that has undermined Republican chances in Virginia,” said Bob Holsworth, a longtime political analyst in the state.

Tuesday’s outcome underlined that fact by showing that even in a year when a huge flow of outside money and big voter turnout brought Virginia Democrats the outcome they wanted, rural parts of the state resisted the trend. Voters there stood with Trump and voted Republican.

The suburbs were the fault lines, the places where the opposite poles overlapped. Partly driven by women’s groups such as the Liberal Women of Chesterfield County, suburban areas broke in favor of Democratic candidates after years of supporting the GOP.

That happened in a big way in Loudoun for Wexton, a state senator who won the rapidly developing bedroom community by a 20-point margin. In 2014, Loudoun went for Comstock over her Democratic opponent by more than 10 percentage points. In 2016, Comstock lost Loudoun by fewer than 200 votes. This year, she lost by nearly 33,000.

In the 2nd District in Hampton Roads, it was an edge in Virginia Beach — a sprawling city that is almost all suburbs — that put Luria past Taylor. Two years ago, Taylor won Virginia Beach over a Democratic opponent by 24 percentage points.

The shift is good news for moderate statewide Democrats such as Sen. Tim Kaine, who easily won reelection Tuesday, and Gov. Ralph Northam, whose win last year capped a huge sweep of victories for his party in the House of Delegates.

But it would be a mistake to conclude that all Virginia suburbs have become blue, Holsworth said. Rather, the suburbs — less crowded than the Democratic cities but more populated than the Republican countryside — are in play in a way they weren’t before.

On Tuesday, Spanberger’s win in the 7th District was a good illustration of the role the suburbs played. The sprawling district stretches from Culpeper County to Nottoway County in the central part of the state and includes neatly ordered suburbs as well as sparsely populated farmland.

Chesterfield, the part of the district that borders Richmond, saw a 25 percent jump in population between 2000 and 2016. While it’s still largely white, the percentages of blacks and Latinos have grown.

As the suburban sections of the 7th District have become more populous and diverse, Republican margins have been shrinking.

Republican presidential candidate Mitt Romney won the district by 11 percentage points in 2012. Trump won it by six in 2016. In the 2017 governor’s race, Republican Ed Gillespie beat Northam there by 3.5 points, although Northam went on to carry the state by a large margin.

“That district is not blue,” Holsworth said. About 35 percent of the voters in the 7th live in rural areas and are reliably red, he said, so a Democrat has to do extraordinarily well in the suburban parts to win the whole district.

Spanberger “had to push those margins up, and she did, then she ran slightly better than Northam [in 2017] in those rural jurisdictions,” Holsworth said. “She doubled Northam’s margin in Chesterfield.”

He credited her energetic campaign, which began more than a year ago and raised the most money of any Virginia congressional candidate. And he faulted Republicans — not only Brat, whose campaign was “almost invisible,” he said, but also Corey A. Stewart, atop the ticket as the Republican nominee for U.S. Senate.

A divisive and bombastic candidate who ran in the mold of Trump, Stewart was toxic to many suburban voters. Other Republicans steered clear of him.

“If the Republicans had a more effective Senate candidate, more money could have come into the state, and there could have been more collaboration with Republican campaigns. And as close as things were in VA-2 and 7, a stronger candidate at the top of the ticket could have made the difference in those House races,” said Stephen Farnsworth, a political scientist at the University of Mary Washington.

Tucker Martin, a longtime GOP strategist, said the suburbs have become more challenging for Republicans because of demographic changes — a problem exacerbated in the Trump era.

“It’s tough out there, man, it’s tough for Virginia Republicans. When President Trump won, they went to the parties and went to the balls. But it’s come with a price in the commonwealth,” said Martin, who was spokesman for the last Republican to win statewide: Gov. Robert F. McDonnell, nearly 10 years ago.

Trump is particularly unpopular in Virginia’s diverse suburbs and among women. Except for Stewart, who likes to say he was “Trump before Trump was Trump,” Virginia Republicans have struggled to find the right tone when campaigning in the president’s shadow. Add to that the huge number of voters who live in suburban swing districts, and the calculus for Republicans is daunting.

But it’s not impossible, Martin said.

“If you look at Larry Hogan in Maryland, Bob McDonnell in 2009, Charlie Baker in Massachusetts — these are candidates who ran very policy-focused campaigns and presented voters with something different,” Martin said. “If you present voters in Virginia, Maryland or Massachusetts with a standard-issue Republican and a standard-issue Democrat, you lose because it’s a math problem. You have to get back to persuading. We actually have to bring voters to our side.”