Michael Bloomberg, billionaire and former Mayor of New York City, speaks at CityLab Detroit, a global city summit, on October 29, 2018 in Detroit, Michigan.

More than $166,000 in contributions, mailings and digital ads to help a political newcomer take on a Republican incumbent in a Richmond-area Senate district. More than $146,000 to help an Air Force veteran seek an open Senate seat in a fast-growing suburban county. About $75,000 to target the only Republican representing Northern Virginia in the state’s House of Delegates.

On Tuesday in Virginia, all three seats flipped from Republican to Democrat – after a $2.5 million spending spree in the state by Everytown for Gun Safety, a gun-control group aligned with billionaire former New York City Mayor Michael Bloomberg. The investments made the Bloomberg-affiliated organization the largest outside spender in the elections that saw Democrats take control of the state’s executive and legislative branches for the first time in a generation.

Everytown officials – who provided CNN with details of their Virginia strategy – say their approach to the off-year election demonstrates the potency of the gun-safety message one year before the nation heads to the polls to decide control of Congress and the White House. The spending also underscores how aggressively the deep-pocketed group will pursue its agenda in the months ahead. Everytown outspent the embattled National Rifle Association by roughly 8-to-1 in Virginia, plowing money into the state to target vulnerable Republicans months in advance of Tuesday’s election.

“Gun safety will be one of the defining issues of 2020,” said John Feinblatt, president of Everytown.

Virginia Republicans went into Tuesday’s election defending paper-thin majorities: 20-19 in the state Senate and 51-48 in the House of Delegates, with a vacancy in each chamber.

Everytown and the Democrats they backed made guns a key issue, following a mass shooting at a Virginia Beach municipal building on May 31 that left 12 people dead. The state’s Democratic Gov. Ralph Northam ordered a special session of the General Assembly in July to take up an array of gun-control bills, but the Republican leadership abruptly ended the session 90 minutes after it started without considering a single bill.

Even before the session began, Everytown strategists began polling to determine which Virginia races would be the most competitive in November should the General Assembly fail to act, said Charlie Kelly, a veteran Democratic strategist who works as a senior adviser to the group.

Soon after the adjournment, the group began a digital advertising blitz to target Republicans, particularly in suburban swing districts. “They made their choice to side with the gun lobby,” Feinblatt said.

Everytown’s spending came as the NRA faces intense scrutiny and legal battles with its former advertising agency. The gun lobby’s finances are under investigation by attorneys general in New York and Washington.

NRA officials this week said it’s not uncommon for Bloomberg-funded groups to outspend them in politics and insisted their membership ranks remained strongly committed to the gun-rights cause.

“Anti-gun organizations are backed by distant billionaires, not local interests,” Jason Ouimet, head of the NRA’s Institute for Legislative Action, said in a statement. “These elitists funnel money into our communities to prop-up weak candidates defined by one trait: their willingness to bow to the billionaire’s gun control agenda, even if it turns great places-like Virginia-into New York City.”

By Election Day, Everytown and its grassroots arm, Moms Demand Action, had endorsed Democrats in 25 races. Moms Demand Action volunteers made more than 100,000 calls to voters, Everytown officials said Wednesday.

Everytown’s heaviest spending went to 15 contests. Those ranged from Washington’s outer suburbs where Democratic state Delegate and Air Force vet John Bell captured an open Senate seat that long had been held by Republicans to the Richmond area, where first-time candidate Ghazala Hashmi ousted a Republican incumbent to become the first Muslim elected to Virginia’s state Senate.

Virginia campaign laws allow outside groups to coordinate directly with candidates and political parties, so Everytown was free to co-produce candidate ads with hyper-local messages. In Bell’s case, Everytown underwrote $75,000 in TV advertising. In one ad, Bell proposed increasing the distance between firing ranges and private homes, highlighting recent incidents in his fast-growing suburban area where stray bullets from private ranges have hit homes.

Everytown also spent more than $67,000 to aid Democrat Shelly Simonds, who gained national attention in 2017 after a tie with her Republican opponent David Yancey was decided by a random draw out of a bowl.

Yancey won the draw two years ago. On Tuesday, Simonds won the rematch by a wide margin.

As of early Wednesday morning, Everytown-favored candidates had won in eight of the 15 races and lost in three. Four still were too close to call.

Among the biggest losses: The group’s attempt to topple Virginia’s Republican House Speaker Kirk Cox. Everytown spent more than $184,000 in that race. Cox survived the onslaught but will have to surrender his leadership position now that Democrats will control the chamber.

While Everytown emerged as one of the biggest players in Virginia’s legislative races, other liberal groups also invested heavily in the state’s races. EMILY’s List, which backs Democratic female candidates who support abortion rights, teamed up with a leading Democratic political action committee, Priorities USA, to spend more than $2 million in Virginia.

A Washington Post poll last month found that gun policy had emerged as the top concern in Virginia, with 75% of registered voters saying it would be a “very important” issue as they cast their ballots in legislative contests.

This story has been updated with additional information provided by Everytown for Gun Safety Wednesday.