President Barack Obama took aim at nativism in his final State of the Union address Tuesday, offering a not-so-veiled jab at politicians, like GOP presidential candidate Donald Trump, who have called for keeping Muslims from entering the country and have denigrated other minorities.

Obama said the U.S. needs "to reject any politics that targets people because of race or religion," not as "a matter of political correctness," but to maintain the country's values.

"It’s a matter of understanding what makes us strong," he said. "The world respects us not just for our arsenal; it respects us for our diversity and our openness and the way we respect every faith."

"When politicians insult Muslims, when a mosque is vandalized, or a kid bullied, that doesn’t make us safer. That’s not telling it like it is," he added. "It’s just wrong. It diminishes us in the eyes of the world. It makes it harder to achieve our goals. And it betrays who we are as a country."

Trump called last month for a "total and complete shutdown of Muslims entering the United States," based on concerns about terrorism. Many Republicans criticized him over the remark, but also joined him in saying refugees from Syria and Iraq should be blocked from the U.S. because they could be terrorists -- a sentiment Obama also rejected at the time.

Obama quoted Pope Francis, who addressed Congress last year and said, "To imitate the hatred and violence of tyrants and murderers is the best way to take their place."

Pool via Getty Images

The president also rejected the idea that immigrants should be blamed for economic ills, another argument common among many Republicans.

"Immigrants aren’t the reason wages haven’t gone up enough; those decisions are made in the boardrooms that too often put quarterly earnings over long-term returns," Obama said.

He came back to the message later, and asked Americans to unite rather than scapegoating others.

"As frustration grows, there will be voices urging us to fall back into tribes, to scapegoat fellow citizens who don’t look like us, or pray like us, or vote like we do, or share the same background," Obama said. "We can’t afford to go down that path. It won’t deliver the economy we want, or the security we want, but most of all, it contradicts everything that makes us the envy of the world."

Read the full text of Obama's last State of the Union address here.

Also on HuffPost:

PHOTO GALLERY Obama's Final State Of The Union