WASHINGTON — President Barack Obama on Sunday marked the 15th anniversary of the Sept. 11 attacks by calling on Americans to embrace the nation’s character as a people drawn from every corner of the world, from every religion and from every background. He said extremist groups will never be able to defeat the United States.

Obama spoke to hundreds of service members, and relatives and survivors of the attack that occurred at the Pentagon when American Airlines Flight 77 slammed into the Defense Department’s headquarters, killing 184 people. The youngest victim was only 3 years old.

In all, about 3,000 people lost their lives that day as a result of the planes that crashed into New York City’s World Trade Center and in a Pennsylvania field.

The president said extremist organizations such as the Islamic State group and al-Qaida know they can never drive down the U.S., so they focus on trying to instill fear in hopes of getting Americans to change how they live.

“We know that our diversity, our patchwork heritage is not a weakness, it is still and always will be one of our greatest strengths,” Obama said. “This is the America that was attacked that September morning. This is the America that we must remain true to.”

Obama spoke on warm, mostly sunny morning, noting that the threat that became so evident on Sept. 11 has evolved greatly over the past 15 years. Terrorists, he said, often attempt strikes on a smaller, but still deadly scale. He specifically cited attacks in Boston, San Bernardino and Orlando as examples.

In the end, he said, the enduring memorial to those who lost their lives that day is ensuring “that we stay true to ourselves, that we stay true to what’s best in us, that we do not let others divide us.”

“How we conduct ourselves as individuals and as a nation, we have the opportunity each and every day to live up to the sacrifice of those heroes that we lost,” Obama said.

Obama’s comments also came in the heat of a presidential election in which voters will weigh which candidate would best keep America safe.

Republican nominee Donald Trump said he would suspend Muslim immigration into the United States, a policy he later amended by saying he would temporarily ban immigration from “areas of the world where there is a proven history of terrorism against the United States, Europe or our allies, until we fully understand how to end these threats.” Obama’s speech Sunday reinforced themes he has emphasized in recent months when he has described Trump’s proposals on Muslim immigration as “not the America we want.”

Obama also marked his final Sept. 11 observance as president with a moment of silence inside the White House to coincide with when the first plane hit the Twin Towers. Atop the White House, the American flag flew at half-staff. Obama invited governors, interested organizations and individuals to follow suit.

Obama said he has been humbled by the people whose 9/11 stories he’s come to learn over the past eight years, from the firefighters who responded to the attacks, to family members of those who died, to the Navy Seals who made sure “justice was finally done” in the killing of al-Qaida leader Osama bin Laden. He said the nation’s security has been strengthened since 9/11 and that other attacks have been prevented.

“We resolve to continue doing everything in our power to protect this country that we love,” he said, facing the benches that are a hallmark of the Pentagon Memorial.

Behind the president, a U.S. flag stretching some three stories tall hung on the section of the Pentagon that was struck on Sept. 11. The president said 15 years may seem like a long time, but he imagined that for the families, it can seem like yesterday. He said he has been inspired by their efforts to start scholarship programs and undertake volunteer work in their communities.

“In your grief and grace, you have reminded us that, together, there’s nothing we Americans cannot overcome,” Obama said.