Democratic presidential candidate Beto O'Rourke compared President Donald Trump's rhetoric on immigration to the nazis.

O'Rourke said he would not use similar rhetoric because "pettiness and meanness" will not help Democrats win.

He has previously been critical of Trump's immigration policies.

Democratic presidential candidate Beto O'Rourke compared President Donald Trump's rhetoric on immigration to Germany under Nazi rule.

During a town hall event in Iowa on Thursday, O'Rourke went after Trump for his past characterizations of undocumented immigrants, describing it as "the rhetoric of a president who not only describes immigrants as rapists and criminals but as animals and an infestation."

Read more: Beto O'Rourke is running for president in 2020. Here's everything we know about the candidate and how he stacks up against the competition.

"Now, I might expect someone to describe another human being as an infestation in the Third Reich," O'Rourke said, referencing Adolf Hitler's vision of Nazi empire. "I would not expect that in the United States of America."

In more detail, O'Rourke listed various examples of Trump's policies and rhetoric.

"Describing immigrants who have a track record of committing violent crimes at a lower rate than native-born Americans as rapists and criminals, seeking to ban all Muslims — all people of one religion — what other country on the face of the planet does that kind of thing?" he said. "Or in history, or in history of the western world?"

"You draw your own conclusions, but this is not something that I expect to hear a president of the United States ever say," O'Rourke added.

O'Rourke also said that "if we descend into that pettiness and meanness and those personal attacks, I'm not sure that we can win."

In the past, O'Rourke has criticized Trump's immigration policies as inhumane and even pledged to tear down existing miles of walls and other physical barriers along the US-Mexico border.