During the administration of President Barack Obama, attorneys general from Republican states developed a powerful tool: They teamed up dozens of times to sue the federal government to block environmental initiatives.

Now, Democrats are using the same playbook to fight the Trump administration.

Blue-state attorneys general have filed more than two dozen environmental lawsuits against the Trump administration since January 2017, and the victories are piling up. This month, a court said the Environmental Protection Agency had broken the law by delaying smog protections. In February, states forced the Department of Energy to enact efficiency standards for household appliances. And in two different decisions in the past year, courts thwarted the administration’s attempts to delay regulations on emissions by the oil and gas industry.

The rise of state attorneys general as partisan warriors against presidential administrations is a relatively new phenomenon, according to some who served in more amicable days. “Up until 1999, the attorneys general were very nonpartisan,” said Grant Woods, a former Arizona attorney general and a Republican. For instance, Republicans and Democrats in the 1990s teamed up to sue the tobacco industry over the health effects of its products and the burdens cigarette smoking placed on state Medicaid budgets.

Mr. Woods recalled that, when pursuing such cases with fellow state attorneys general, he was not even sure of some colleagues’ party affiliations. “Today everyone has it branded on their forehead, like a scarlet letter,” he said.