WASHINGTON — President Donald Trump clearly didn't like the way House Speaker Nancy Pelosi's fight with "The Squad" was playing out for him.

After Rep. Alexandria Ocasio-Cortez, D-N.Y., accused Pelosi of being "disrespectful" to young women lawmakers of color, Democrats on Capitol Hill rallied to Pelosi's corner and distanced themselves from the four congresswomen who have become the latest avatars of liberal politics in Republican attacks.

That was the opposite of the political dynamic he needs as he faces re-election — he wants the Democratic Party stuck to its progressive fringe so that he can portray his opponents as too extreme to lead the country — and he moved quickly to flip the script.

On Sunday, Trump unleashed a racist Twitter tirade against The Squad — Ocasio-Cortez and Reps. Rashida Tlaib, D-Mich., Ilhan Omar, D-Minn., and Ayanna Pressley, D-Mass. — in which he said they should "go back" to their home countries before advising America on its governance. They're all U.S. citizens, and three of them were born in the United States — facts that only increased the likelihood that his tweets would bring swift condemnation.

They did.

"When @realDonaldTrump tells four American Congresswomen to go back to their countries, he reaffirms his plan to 'Make America Great Again' has always been about making America white again," Pelosi wrote on Twitter.

Trump's gambit worked well enough that the four congresswomen held a press conference late Monday to call an end to hostilities — even as they charged him with violating the Constitution, international human rights standards and basic decency.

"I encourage the American people and all of us in this room and beyond to not take the bait," Pressley said. "This is a disruptive distraction from the issues of care, concern and consequence for the American people."

Tlaib called Trump's rhetoric "disgusting, bigoted language."

Omar said it was "the agenda of white nationalists, whether it is happening in chat rooms or it's happening on national TV and now it’s reached the White House garden."

All four lawmakers listed issues they are working on — from health care to immigration — that they believe the president is trying to distract from.

It doesn't require anyone else to explain Trump's thinking. He provided a road map after receiving a cascade of criticism from Democrats and independent commentators.

"So sad to see the Democrats sticking up for people who speak so badly of our Country and who, in addition, hate Israel with a true and unbridled passion. Whenever confronted, they call their adversaries, including Nancy Pelosi, 'RACIST,'" Trump tweeted Sunday night.

While Democrats aren't likely to see any similarity between Trump's record and Ocasio-Cortez's shot at Pelosi — she said it was "stupidly untrue" to think she had played the "race card" against Pelosi — Trump surely saw an opportunity to frame the pair of dust-ups for his own base and swing voters as twin examples of Democrats unfairly accusing political rivals of racism.

And while many Democrats disagree with The Squad on policy or tactics as much as they did before the weekend, the collective defense means there is now a public show of solidarity.

As much as it's a mistake to think that every slur Trump issues with his mouth or his fingertips provides evidence he's a master of advanced game theory, it's also an error to assume there's no method to his messaging.

Several of the states at the heart of his re-election hopes include major populations of foreign-born citizens, including centers in Omar's Minneapolis-based district and Tlaib's district, which takes in parts of Detroit and its suburbs. Foreign-born citizens account for 30 percent of the people in South Florida's 25th Congressional District, according to census data, and represent significant shares of the population in a number of districts across the state, as they do in pockets of Virginia, North Carolina, Nevada, Arizona, Pennsylvania and Georgia.

But in each of those potential swing states, they remain a small minority of the overall population — and Trump's divisive rhetoric could help foster a backlash against immigrants. By associating Democrats with lawmakers he brands socialists, he may also be able to peel off foreign-born citizens who departed countries with leftist governments. He is likely to have a ready audience for that message among some citizens of Florida who left Latin American nations.

"They're socialists, definitely," Trump said of the four congresswomen during remarks at the White House on Monday. "They hate our country."

Though Ocasio-Cortez and Tlaib identify as "Democratic Socialists," Pressley and Omar do not, and all four have expressed and demonstrated their love of the United States.

"Every single statement we make is from the place of extreme love for every single person in this country," Omar said Monday.

In addition to pushing Democrats to embrace members of their party on the left, the other benefit for him is that turning the fight into cultural warfare has distracted from criticism of a border policy that has resulted in the use of mass detention camps while failing to achieve his promises of stopping illegal immigration, building a major wall along the U.S.-Mexico border and deporting millions of undocumented immigrants currently in the U.S.

"Let's not forget why Trump is attacking Democratic women of color in the first place: They brought attention to the inhumane conditions they saw at this administration's detention camps," former Secretary of State Hillary Clinton, the Democratic presidential nominee who lost to Trump in 2016, wrote on Twitter on Monday.

Trump and his defenders said that his tweets — nearly a dozen over two days — were about patriotism, not race.

"Their disgusting language and the many terrible things they say about the United States must not be allowed to go unchallenged," he tweeted after the initial backlash. "If the Democrat Party wants to continue to condone such disgraceful behavior, then we look even more forward to seeing you at the ballot box in 2020!"

But it was Trump who campaigned in 2016 on the idea that America was not great under President Barack Obama, an American whom he long sought to portray as foreign-born as part of a "birther" campaign. Trump's slogan was "Make America Great Again." In his inaugural address in 2017, he spoke of the "American carnage" he saw across the nation.

"For him to condemn us and to say that we are un-American for wanting to work hard to make this country the country we all deserve to live in is complete hypocrisy," Omar said Monday.

Trump's point may be that he wants Americans who don't like his policies or him to leave the country, whether they were born here or not. He said Monday that he's not worried that his targeting of four women of color — all of whom swore oaths to uphold the Constitution — has been denounced as racist.

"It doesn't concern me," he told reporters at the White House. "Many people agree with me."

That, in short, is his calculation for 2020, whether or not his calculation turns out to be a smart one: that pairing The Squad and the rest of the Democrats helps pave the path to a second term.

And as the group again claimed the spotlight during their Monday press conference, the president congratulated himself on his strategy's success. "The Dems were trying to distance themselves from the four 'progressives,'" he tweeted — "but now they are forced to embrace them."