In the midst of intra-party fighting among Democrats, President Trump jumped in to bash “the Squad” for their anti-American rhetoric.

Some immediately thought the president had blundered, but in reality he succeeded in forcing the entire party to defend its most extreme members — Reps. Ocasio-Cortez of New York, Ilhan Omar of Minnesota, Rashida Tlaib of Michigan or Ayanna Pressley of Massachusetts.

“The President won this one,” one Democratic lawmaker in the House told CNN. “What the President has done is politically brilliant. Pelosi was trying to marginalize these folks, and the President has now identified the entire party with them.”

Another Democrat said Trump outplayed them by setting the agenda.

TRENDING: BREAKING: Black Lives Matter Rioters in Hollywood Chase Down and Attack Driver.. UPDATE... DRIVER DETAINED BY POLICE (SHOCKING VIDEO)

“We need to focus on the issues that got [Democrats] here: jobs, health care … instead of the issues the President brings up deliberately. Anything that takes away from bread-and-butter issues is playing into his hands,” said the lawmaker.

Some Democrats are also increasingly frustrated with the four lawmakers, who have been front and center during a contentious fight over funding for the U.S.-Mexico border. Ocasio-Cortez claimed House Speaker Nancy Pelosi was being racist as she snubbed “The Squad” and backed moderate Democrats. That led to fiery criticism from several of the four lawmakers, which has “annoyed” some Democrats.

“I can’t tell you the number of members who are angry and annoyed about them criticizing us,” said one House Democrat.

“Less than two weeks ago when members of our caucus were trying to support funds for children at the border,” progressives were arguing that “we’re pro-putting kids in cages, we’re against human rights. So there’s frustration,” said another House Democrat.

Trump kicked off the battle with several posts on Twitter over the weekend.

“So interesting to see ‘Progressive’ Democrat Congresswomen, who originally came from countries whose governments are a complete and total catastrophe, the worst, most corrupt and inept anywhere in the world (if they even have a functioning government at all), now loudly and viciously telling the people of the United States, the greatest and most powerful Nation on earth, how our government is to be run,” Trump tweeted Saturday.

“Why don’t they go back and help fix the totally broken and crime infested places from which they came. Then come back and show us how it is done. These places need your help badly, you can’t leave fast enough. I’m sure that Nancy Pelosi would be very happy to quickly work out free travel arrangements!” the president tweeted.

Trump later revealed his strategy, writing, “The Dems were trying to distance themselves from the four progressives, but now they are forced to embrace them. That means they are endorsing Socialism, hate of Israel and the USA! Not good for the Democrats!”