IN 2014, Dave Brat, an ally of President Donald Trump, was the face of the nascent anti-establishment insurgency, beating Eric Cantor, then the second most powerful Republican in the House of Representatives. Four years later, Mr Brat is on his way out, having been denied a third term by a Democratic newcomer who harnessed the anti-Trump fury of this year’s most prized voters: affluent, well-educated suburban women.

The ascent of Abigail Spanberger, a former CIA case officer, was meteoric, rather like the change that is remaking Virginia’s seventh district, a mix of leafy suburbs and rolling farmland close to Richmond, the state’s capital. Though the district tipped to Donald Trump in 2016 and to the unsuccessful Republican nominee for governor, Ed Gillespie, the following year, voters in its Chesterfield County and Henrico County suburbs have become increasingly disenchanted with President Donald Trump, his assault on the Affordable Care Act, and his hostility towards immigrants. Last year, Chesterfield backed a Democrat for governor for the first time since 1961.

These traditionally Republican suburbs, which swelled in the 1960s with conservative whites fleeing heavily African-American Richmond during the struggle over public school desegregation, are now moderate and multihued. Thanks in part to the presence of several global companies Chesterfield and Henrico now brim with younger, non-native professionals, including large numbers of Asians and Hispanics.

The manner in which the seventh district has changed is emblematic of the Republican Party’s bigger problem in Virginia: it is fading in the suburbs. In the tenth district, in the Northern Virginia suburbs of Washington, DC, Jennifer Wexton beat the Republican incumbent, Barbara Comstock. The district had not elected a Democrat to the House for 36 years. In the seventh, Ms Spanberger’s healthy majorities in heavily-populated Chesterfield and Henrico more than offset Mr Brat’s victories in the district’s eight other counties—all of them rural and Trump-friendly.

Mr Brat’s troubles were evident in the opening days of the Trump administration, when the congressman was besieged by constituents angry over the Republican assault on health care. The most outspoken were women, whom Mr Brat, a former economics professor, complained, “get in my grill no matter where I go.” Comments such as these, as well as outrage over Mr Trump, sparked furious exchanges at heavily attended town hall-type meetings, and Mr Brat took his re-election campaign underground. His appearances, including with Mike Pence, the vice-president, and Paul Ryan, the Speaker, were often invitation-only. The media was not informed of his movements. All this fed a perception that Mr Brat was distant and arrogant.

Ms Spanberger, by contrast, came across as cool, approachable and engaged. Her national security credentials—before the CIA, she investigated money laundering and drug trafficking for the US Postal Service—made it difficult for Republicans to depict her as another wimpy Democrat. (They had the same problem with Elaine Luria, a retired Navy commander, who scored a surprise victory against Scott Taylor, a former Navy seal, in Virginia’s second district.)

Republicans tried another line of attack on Ms Spanberger. Television commercials (paid for by a super-PAC aligned with Mr Ryan) highlighted her work as a substitute teacher at a Muslim academy in Northern Virginia whose graduates included two accused terrorists. Ms Spanberger had taken the job while she was waiting for her security clearance after receiving a job offer from the CIA. The ad seemed to fall flat with voters.