Letitia James, the Democratic nominee for attorney general in New York, speaks in opposition to the Trump administration's travel ban in 2017.Frank Franklin II / AP

The Democrat Phil Weiser decided to run for Colorado attorney general the night Donald Trump was elected president, he explains earnestly in a recent campaign ad. “Ever since, I’ve been writing down all the ways I could protect Colorado from Donald Trump,” voice-over Phil Weiser says, as physical Phil Weiser bolts up in bed, struggles to shave one-handed, and pauses while pulling out of his garage, all while scribbling out those plans on whatever surface he can find.

His ideas pop up on the screen to the sound of a scratching Magic Marker. “Defend DACA + the dreamers.” “Protect Obamacare.” “Ban bump stocks.”

In an unusually high-octane year for state-attorney-general elections, Democrats see Weiser as one of their best shots at picking up a seat, and see his message as one of the best they’ve got: A vote for us, they say, is a vote against Trump.

Of all the many fighters of the Trump resistance, Democratic attorneys general may have the most teeth. As their state’s top lawyer, they wield unique standing to sue over major Trump policies. And sue they have: In the first two years of the Trump administration, Democratic attorneys general have won some of the left’s most significant victories against the administration, on issues from immigration to education to the environment.

Now they’re hoping those wins can help them take back Republican-held seats in this fall’s battleground-state midterm elections.

Republicans currently hold the majority of state-attorney-general seats, 27 to 22, with one independent. But this fall’s map—there are more than 30 races on the ballot—has put the GOP on defense, with 18 seats to protect and battlegrounds that seem to favor the blue team.

In New York, where the attorney-general post is all but certain to remain in Democrats’ hands, primary candidates practically tripped over one another promising to take Trump to court.

Zephyr Teachout, who ultimately lost out to her fellow Democrat Letitia James, launched her campaign in June in front of Trump Tower with a pledge to investigate Trump’s private-business interests in New York. “The beating heart of Trump’s corruption is here in our state,” she said.

In her victory speech last month, James told a crowd that her race “was never really about me or any of the candidates who ran.” Instead, she said, “mostly it was about that man in the White House who can’t go a day without threatening our fundamental rights.”

Attorneys general haven’t traditionally been overtly political—they defend state agencies in court, ensure child support is paid on time, and go after companies that defraud consumers. But over the past decade, with an ever-growing stack of lawsuits against the federal government, Republican and Democratic attorneys general alike have nudged those law-and-order postings into the partisan fray, a process that culminated last March in a Republican-initiated rules change allowing national parties to target the opposition’s incumbents.

That’s set this year to be the costliest attorney-general election cycle to date, with an expected $100 million spent on the races. And it’s why Weiser is banking on national political tailwinds to rev up—and fund—his flyover-state race.

“I just have some work to do,” Weiser concludes his video, scribbling.

Trump had been in office less than a month when Democratic attorneys general landed their first major hit.

In the first weeks of the new administration, five attorneys general took Trump to court over his original travel ban, which limited immigration from seven predominantly Muslim countries. In February 2017, a federal judge sided with Washington Attorney General Bob Ferguson, blocking the policy nationwide.

They only gained momentum from there. Democratic attorneys general sued to keep Trump from ending the Deferred Action for Childhood Arrivals program. They sued to stop him from banning transgender individuals from military service. They sued to block his Education Department from delaying student protections from for-profit colleges.

New York’s attorney general took 100 legal or administrative actions against the administration in under a year. California’s office got a $6.5 million budget influx to keep its anti-Trump efforts going. Even in smaller states, like Hawaii and Connecticut, Democrats weaponized their offices against a president they said was ignoring the rule of law, and they notched major victories.

But Democratic attorneys general showed up to the playoffs with the shallowest bench they’d had in decades. The party used to have a stranglehold on the seats: In 1980, Democrats owned 33 seats to Republicans’ 17, and over the following three decades that majority seldom dipped below 30. Their blue tide began to recede in 2011, following the first midterm election under President Barack Obama; in 2012, the split stabilized at 25–25; and finally, after the 2014 midterms, the advantage flipped for the Republicans.

This year, Democrats are hoping to retake that majority by touting their tussles with Trump. Their case to voters is simple: Our party has had more success in the courthouse than the statehouse. Help us keep up that fight.

“It’s the one office that has shown the power to put a halt on the egregious actions of this administration,” said Sean Rankin, the executive director of the Democratic Attorneys General Association (DAGA). “Congress has continued to fall short in its responsibility of acting as a check on the executive, and it’s been the Democratic attorneys general who have most effectively shown that they can actually handle the load and hold this administration accountable when it fails to understand what it means to follow the law.”

Democrats didn’t invent this strategy—they borrowed it from their colleagues across the aisle.

In 2007, a U.S. Supreme Court case called Massachusetts vs. Environmental Protection Agency found that states have “special solicitude” to sue the federal government. As the Obama administration found its footing, and especially as it turned to making policy through executive actions in the face of a gridlocked Congress, Republican state attorneys general seized that solicitude as a political weapon, launching a series of multistate legal challenges to Obama’s policies. Since then, said Paul Nolette, a political-science professor at Marquette University who tracks this type of litigation, the number of such lawsuits has gone “off the charts.”

In Obama’s first term, Republican attorneys general brought 14 multistate lawsuits against the federal government, according to Nolette. In Obama’s second term, that number more than doubled. Republican states challenged dozens of environmental regulations and immigration actions. Their lawsuits effectively killed the Clean Power Plan, a landmark Obama-era environmental rule, and the Deferred Action for Parents of Americans and Lawful Permanent Residents program, an expanded version of DACA that would have granted deportation stays to millions.

That success made for good campaign slogans, though the day-to-day duties of the office hadn’t changed much.

Republican Governor Greg Abbott of Texas used to say his job as the state’s attorney general was simple: “I go into the office, I sue the federal government, and I go home.” The wife of his successor, Ken Paxton, has taken it one step further, adding a guitar. “I’m a pistol-packin’ mama, and my husband sues Obama,” she would croon at campaign events.

Now Democrats have adopted both the messaging and the means. In borrowing Republicans’ strategy, though, Democrats have outpaced them. In less than two years of the Trump administration, Democrats have already lobbed nearly 60 multistate lawsuits—more than Republicans brought in the eight years of Obama’s presidency.

That stack will only grow if Democrats can boost their numbers this fall—one reason both sides have invested so heavily in the dozens of races. The Republican Attorneys General Association will spend about $40 million this cycle to DAGA’s $16 million.

Polls show close races in Florida, Ohio, Wisconsin, Arizona, and Nevada. Those contests have become both pricey and ugly.

In the battleground state of Nevada, Republicans have targeted the Democrat Aaron Ford for four arrests in his 20s, including for theft and for failing to appear in court. In Florida, the Republican Ashley Moody has aligned herself with the president while the Democrat Sean Shaw has pledged to investigate him.

And in Minnesota—one of the GOP’s only likely pickups—a safe seat for Democrats is at risk after their nominee, U.S. Representative Keith Ellison, was accused of assaulting an ex-girlfriend, allegations he denies. A recent poll has the Republican candidate, Doug Wardlow, leading by seven points in a seat Democrats have held for decades. Perhaps the most telling sign of partisanship in that race: Wardlow has privately promised that he would “right off the bat” fire 42 Democrats working in the state attorney general’s office.

In many of the states on the ballot this fall, attorney-general candidates are bickering over a state-led lawsuit to kill the Affordable Care Act. Texas and Wisconsin launched that 20-state challenge in February; California leads a similar-size group of states in defending the landmark health law. Now, in states that are on Team Texas, Democrats are running on promises to bow out of the legal challenge, or to switch sides entirely. In many states, the dispute has become not whether to fight the federal government at all, but which side to take.

The “fighting the feds” rhetoric has politicized an office once considered about as interesting as state dogcatcher, and it’s cost taxpayers millions of dollars. But it’s also added a new high-stakes dimension to what had been sleepy, down-ballot races.

George Brauchler, the Republican running against Weiser in Colorado, called this politicization of the office inappropriate.

“Attorneys general have become these ideological Don Quixotes, finding all these different political issues to tilt at like windmills,” Brauchler lamented. “Both sides look at this like, ‘Wow, we can almost stop this administration in its tracks.’ That’s an incredible amount of power.”

In March 2017, high off an unexpected presidential victory and surging with 28 strong, their highest tally in decades, Republican attorneys general convened on a private conference call. There were deliberations. Then they voted, 15–8, to take the gloves off.

For decades, the incumbency rule had kept the Republican Attorneys General Association (RAGA) and the Democratic Attorneys General Association from financially backing challengers to each other’s incumbents—it had kept elections cheaper, boosted cooperation across state and partisan lines, and reflected the races’ comparatively lower political temperatures. Who cares, the thinking went, if the lawyer defending state agencies is a Republican or a Democrat? But that no longer applied in an increasingly polarized political environment.

For Republicans, the justification was simple.

“The stakes are too high for us to leave winnable races on the table,” Scott Will, RAGA’s executive director, said at the time.

However pragmatic its goals, some strategists believe abandoning the rule may have backfired for Republicans this cycle. RAGA is slightly older, and far better funded than its Democratic counterpart. But this year, it has more seats to defend—and it has to spend seriously to keep its incumbents in office.

The rules change has Democratic strategists eyeing—albeit with rose-tinged optimism—even Republican strongholds like Georgia and Texas. But they see their likeliest bets at unseating Republican incumbents in Arizona and Wisconsin, where they’ve run young, charismatic candidates against first-term Republican incumbents.

The rules change gives challengers a financial boost from their national parties. In Arizona, DAGA has supported the challenger, January Contreras, with a $1.75 million allocation, money it couldn’t have spent with the incumbency rule in place. In turn, RAGA has allocated $2.5 million in TV advertising to keep the incumbent, Mark Brnovich, in office.

Abandoning the incumbency rule has “absolutely” shifted the tables in Democrats’ favor this year, Rankin said.

“The simple answer is yes. Because prior to the rule [change] I would not have been allowed to invest funds into those states to support those candidates,” he said. “We’ve got a set of wins that I think are gonna come—enough opportunities on a big map that’s continued to get bigger. I’m pretty excited about Election Night.”

Republicans, meanwhile, are downplaying the impact of the rules change—these tight races, they say, would have been tight races regardless. Wisconsin is typically a toss-up state, and the incumbent, Brad Schimel—whom a Madison newspaper labeled the “worst attorney general in Wisconsin history”—would have always had a difficult road to reelection. And politicos have long speculated that Arizona’s shifting demographics would soon turn the state blue, or at least more purple.

Will said the incumbency rule change “will have no practical impact in 2018 due to the map.”

“The fact is, Democrats were always going to come after our incumbents,” Will said. “The battlefield is expansive because of RAGA’s recent domination of AG races. We have experienced candidates ready to serve on day one—ready to keep people safe in their communities.”

In tight races and in states viewed as long shots, Democrats are hitting Republican incumbents as hard as they can.

In Texas, where the gap looks difficult to close, the challenger, Justin Nelson, has all but attached the word indicted to the name of Ken Paxton, the Republican incumbent, who was charged in 2015 with felony securities fraud. Paxton will face voters before he faces a jury.

In Wisconsin, a closer race, the Democrat Josh Kaul has bludgeoned his opponent repeatedly over the Obamacare lawsuit, and he’s enjoyed a boost from the $2 million DAGA allocated to support him.

Arizona’s Contreras hasn’t been as explicit about running against Trump as Weiser, hundreds of miles northeast in Colorado. But in a state led by Republicans from the governor’s mansion straight on down through mine inspector, she’s touting endorsements from Obama and former Vice President Joe Biden. She’s also promised to flip Arizona’s position on the Obamacare lawsuit, fighting to preserve the law instead of to dismantle it.

Contreras said she wanted to run because in Arizona, state officials are running amok and “the courts are the adults in the room.”

“And I could see that happening at the national level as well,” she said. “That was a moment for me to say: The AG really matters.”

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.