Donald Trump used racist language on Sunday to attack four progressive Democratic congresswomen, telling them to “go back and help fix the totally broken and crime-infested places from which they came”.

The US president did not name his targets, but the attack was directed at a group of liberal congresswoman who have had a run-in with the House speaker, Nancy Pelosi, and who are sometimes referred to as the “squad”: Alexandria Ocasio-Cortez of New York, Ayanna Pressley of Massachusetts, Rashida Tlaib of Michigan and Ilhan Omar of Minnesota.

Only Omar, who is from Somalia, was not born in America. Pressley is African American, Tlaib was born to Palestinian immigrants and Ocasio-Cortez comes from a New York-Puerto Rican family.

Tlaib responded by saying Trump “needs to be impeached”. Ocasio-Cortez said: “The country I ‘come from’, and the country we all swear to, is the United States.”

Omar called Trump “the worst, most corrupt and inept president we have ever seen”. Pressley said: “This is what racism looks like. We are what democracy looks like.”

Bernie Sanders was among others who called the attack racist. “When I call the president a racist, this is what I’m talking about,” the Vermont senator wrote on Twitter.

Justin Amash, a Michigan congressman who left the Republican party over his opposition to Trump, called the remarks “racist and disgusting”.

Trump responded to the outcry on Twitter on Sunday evening, saying it was “sad to see the Democrats sticking up for people who speak so badly of our country”.

....and the many terrible things they say about the United States must not be allowed to go unchallenged. 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! — Donald J. Trump (@realDonaldTrump) July 15, 2019

Earlier Nihad Awad, national executive director of the Council on American-Islamic Relations, said: “If Trump shouted the same thing at a Muslim woman wearing hijab in a Walmart, he might be arrested.”

The congresswomen targeted by the president have been engaged in a dispute with Pelosi over the humanitarian crisis at the southern border and her reluctance to begin impeachment proceedings. Ocasio-Cortez told the Washington Post that Pelosi’s “explicit singling out of newly elected women of color” was “outright disrespectful”. On Friday Trump defended Pelosi, saying: “She is not a racist.”

In tweets on Sunday, the president wrote that it was “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.

Congresswoman Ilhan Omar was born in Somalia and came to the US in the 1990s. Photograph: Jim Bourg/Reuters

“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!”

Pelosi responded by saying Trump had shown that his plan to “Make America Great Again” had “always been about making America white again”.

The California senator Kamala Harris said Trump’s comments were “absolutely racist and un-American”.

The presidential trolling may have been meant as a distraction from immigration raids that were due in major cities on Sunday.

It is far from the first time Trump has been accused of holding racist views. He launched his political career with false claims that Barack Obama was not born in the US and his presidential campaign with the claim many Mexicans were “rapists”. Last year during a White House meeting he wondered why the US was admitting migrants from “shithole countries” like Haiti, El Salvador and several African nations.

On CNN’s State of the Union on Sunday, Ken Cuccinelli, the acting director of US Citizenship and Immigration Services, was asked whether Trump’s tweets “feed into this impression that the president is racist and is pushing a racist agenda”. Cuccinelli said the tweets were examples of “rhetoric for the presidential race”.

All the congresswomen have emerged as key voices in a Democratic party split over how to beat Trump at the polls. Omar was born in Somalia and came to the US at 12 after a spell in a refugee camp. Elected to Congress in November as one of its first two Muslim women, she has emerged as a hate figure for Fox News hosts and Trump’s hard-right support. Tlaib, the other Muslim woman in Congress, was born in Detroit. Pressley was born in Cincinnati. Ocasio-Cortez was born in New York.

Trump has regularly attacked Omar and ridiculed Ocasio-Cortez, although a new book does contain expressions seemingly signalling respect for the New Yorker.

The Texas congressman Lloyd Doggett said on Twitter Trump’s attack was “racism pure and simple” but perhaps unwittingly echoed attacks on Pelosi when he said the president “fears the power of these strong, effective, American women of color”.

Sanders told NBC’s Meet the Press Pelosi was being “a little bit” too tough on the congresswomen and said: “You cannot ignore the young people of this country, who are passionate about economic and racial and social and environmental justice.”

On Sunday Tlaib was the first of the targeted women to respond to Trump. “Want a response to a lawless [and] complete failure of a president?” she wrote. “He is the crisis. His dangerous ideology is the crisis. He needs to be impeached.”

Omar, Pressley and Ocasio-Cortez followed, the last with a lengthy rebuke. “You are angry because you don’t believe in an America where I represent New York 14, where the good people of Minnesota elected [Omar], where [Tlaib] fights for Michigan families, where [Pressley] champions little girls in Boston,” she wrote. “You are angry because you can’t conceive of an America that includes us. You rely on a frightened America for your plunder.”