US Representatives Ayanna Pressley (R), Rashida Tlaib (second from R), Alexandria Ocasio-Cortez (third from R) and Ilhan Omar (L)

The US House of Representatives formally condemned Donald Trump on Tuesday for xenophobic attacks on four minority Democratic lawmakers and hostile language targeting immigrants, as the president denied accusations of racism.

Top Republican leaders rallied around Trump, but four members of the president's party voted with the 235 Democrats to condemn him for "racist comments that have legitimized and increased fear and hatred of new Americans and people of color."

One independent lawmaker also supported the measure, which takes aim at Trump's weekend tweets telling a group of progressive Democratic congresswomen of color to "go back" to other countries.

The resolution also takes the president to task for "referring to immigrants and asylum seekers as 'invaders.'"

Trump has a long history of pandering to white suspicions about other ethnic groups, and the resolution criticizes him for "saying that Members of Congress who are immigrants (or those of our colleagues who are wrongly assumed to be immigrants) do not belong in Congress or in the United States of America."

Democrats hold a majority in the 435-member House but are outnumbered by Republicans in the Senate, where the resolution is unlikely to be considered.

The four congresswomen -- all but one of whom were born in the US -- are of Hispanic, Arab, Somali and African-American descent.

Trump has stuck by the provocative comments.

"Our Country is Free, Beautiful and Very Successful. If you hate our Country, or if you are not happy here, you can leave!" the president tweeted Tuesday.

Democratic leaders denounced Trump's remarks, and rallied around the lawmakers -- Alexandria Ocasio-Cortez, Rashida Tlaib, Ilhan Omar and Ayanna Pressley.

Omar is the only one born outside the United States.

Slamming the "so-called vote" as a "Democrat con game," Trump urged Republicans not to "show 'weakness' and fall into their trap."

"Those Tweets were NOT Racist. I don't have a Racist bone in my body!" Trump said.

"This should be a vote on the filthy language, statements and lies told by the Democrat Congresswomen, who I truly believe, based on their actions, hate our Country," he wrote.

"Nancy Pelosi tried to push them away, but now they are forever wedded to the Democrat Party," Trump added, in a jab at the House speaker who has had a tenuous relationship with the four left-leaning first-term congresswomen.

Speaking on the House floor prior to the vote, Pelosi said: "Every single member of this institution, Democratic and Republican, should join us in condemning the president's racist tweets."

"To do anything less would be a shocking rejection of our values and a shameful abdication of our oath of office to protect the American people."

"I know racism when I see it. I know racism when I feel it. And at the highest level of government, there's no room for racism," Representative John Lewis, an American civil rights icon, said in remarks on the House floor.

'All about politics'

Trump's repeated attacks appear to be aimed at galvanizing his mostly white electoral base ahead of the 2020 presidential vote.

"See you in 2020!" said Trump, who before becoming president pushed the racist "birther" conspiracy theory that Barack Obama was not born in the United States.

Ocasio-Cortez dismissed Trump's denial that he is a racist.

"You're right, Mr. President -- you don't have a racist bone in your body," she tweeted. "You have a racist mind in your head, and a racist heart in your chest."

She also took aim at Republican lawmakers who voted against the resolution, telling CBS News that "they could not bring themselves to have the basic human decency to vote against the statement that the president made."

Trump meanwhile took to Twitter on Tuesday night to hail "how unified the Republican Party was on today's vote."

While some Republican members of Congress have condemned Trump's remarks, House Republican leaders closed ranks behind the president.

"This is all about politics," said House Republican minority leader Representative Kevin McCarthy of California.

Senator Mitch McConnell, the leader of the Republican majority in the Senate, said "the president is not a racist."

Immediately after the House vote a Democratic congressman, Al Green of Texas, filed articles of impeachment against Trump.

Dozens of other Democratic members of the House have reportedly called for an impeachment inquiry to be opened against the president but Pelosi has said she does not favor such a move at the moment.