But once in office, he relished warring with Democratic governors and mayors. He attacked blue states for “sanctuary” policies resisting cooperation with federal immigration crackdowns, and he has sought to penalize states like deep-blue California for environmental policies that go beyond the standards he has set at the federal level. More recently, he threatened to take funds from four “anarchist jurisdictions” with Democratic mayors who in his view have not done enough to suppress protests against racial injustice that turn violent.

Mr. Trump set the tone early with the signature tax cut legislation that passed in 2017 and limited the federal deduction for state taxes, effectively raising taxes on many high-income earners in blue states and creating what Gov. Andrew M. Cuomo of New York at the time called “an economic civil war” between blue states and red states. Mr. Trump subsequently changed his own residence from blue New York, where the tax change hit hard, to the redder Florida, where there is no state income tax. He has urged others to leave New York as well.

“Trump has never seen himself as president of the United States,” said Stuart Stevens, a top strategist to Mitt Romney when he was the Republican presidential candidate in 2012 and now an outspoken critic of Mr. Trump. “He’s a gang leader, and you are either in his gang or you are the enemy.”