President Obama used his speech on Sunday commemorating the 15th anniversary of the Sept. 11, 2001, attacks on the United States to remind Americans that the country’s “greatest strength” is its diversity and to urge its citizens to reject those seeking to divide them.

Obama spoke at the Pentagon, standing in front of a large American flag draped over the spot where a plane hit the building 15 years earlier. His address praised the military and paid homage to those who lost their lives in New York, Washington and Pennsylvania that day, but it also carried a more pointedly political message.

At a time when Donald Trump, the Republican nominee for president, has called for a ban on Muslims entering the United States, Obama outlined a contrasting vision. He offered a different definition of American strength.

“Groups like al-Qaeda and ISIL know that they will never be able to defeat a nation as great and as strong as America,” Obama said, using an alternative acronym for the Islamic State militant group. The goal of those terrorist groups, he said, is to “stoke enough fear that we turn on each other as a nation, that we change who we are and how we live.”

He urged Americans to view the anniversary of the attacks as an opportunity to “reaffirm our character as a nation” and, in what could be interpreted as a veiled reference to Trump’s immigration proposals, “not to let others divide us.”

“In the end, the most enduring memorial to those we lost is ensuring the America we continue to be,” Obama said. “That we stay true to ourselves. That we stay true to what’s best in us.”

Obama described an America made up of “people drawn from every corner of the world, every color, every religion every background.”

“We know that our diversity, our patchwork heritage is not a weakness,” he said. “This is the America that was attacked that September morning.”

The president’s speech was preceded by more bellicose remarks from Defense Secretary Ashton B. Carter, who warned that terrorists who threaten the United States will “come to feel the righteous fist of American might.”

“Our memory is long, and our reach and resolve is endless,” Carter said.

Obama similarly praised military, intelligence and homeland security officials who have “risked their lives to keep us safe.” He briefly mentioned troops still fighting in Iraq and Afghanistan — two wars that will go down as among the longest in American history.

And he described the evolution of the terrorism threat away from elaborate, large-scale attacks toward smaller, deadly strikes like those carried out in recent years in Boston,  Orlando and San Bernardino, Calif. He said such attacks, intended to incite panic, also would fail.

“As Americans, we do not give into fear,” Obama continued. “We will preserve our freedoms, a way of life that makes us a beacon to the world.”