President Trump delivered a stern warning to extremist groups threatening the U.S. on the anniversary of the Sept. 11, 2001, terror attacks, his first commemoration of the somber occasion as president.

Speaking at the Pentagon on Monday, where one of four hijacked planes crashed 16 years ago, Trump mourned those who died and said he would honor the sacrifice by doing “whatever we must to keep our people safe.”

“The terrorists who attacked us thought they could incite fear and weaken our spirit,” he said. “But America cannot be intimidated, and those who try will soon join the list of vanquished enemies who dared to test our mettle.”

ADVERTISEMENT

He vowed U.S. armed forces would ensure al Qaeda and other extremist groups would never be given a “sanctuary” from where they could plot and launch a similar attack again.

“We are making plain to these savage killers that there is no dark corner beyond our reach,” the president said.

"When America is united, no force on earth can break us apart," he added.

Trump spent much of his Monday morning at remembrance ceremonies for the nearly 3,000 people killed in the attacks.

He laid a wreath at a Pentagon observance also attended by Defense Secretary James Mattis James Norman MattisBiden courts veterans amid fallout from Trump military controversies Trump says he wanted to take out Syria's Assad but Mattis opposed it Gary Cohn: 'I haven't made up my mind' on vote for president in November MORE and Marine Corps Gen. Joseph Dunford, the chairman of the Joint Chiefs of Staff

The president, a native New Yorker, joined first lady Melania Trump in observing a moment of silence at the White House at 8:46 a.m., marking the moment when the first plane hit the World Trade Center.

Vice President Mike Pence Michael (Mike) Richard PenceMomentum growing among Republicans for Supreme Court vote before Election Day Sunday shows preview: Justice Ginsburg dies, sparking partisan battle over vacancy before election McConnell urges GOP senators to 'keep your powder dry' on Supreme Court vacancy MORE attended a ceremony at the 9/11 memorial in Shanksville, Pa., where another hijacked plane went down.

The anniversary came as the country struggles with the widespread destruction caused by hurricanes Harvey and Irma. Trump drew a parallel between the nation’s response to the terror attacks and natural disasters, saying, “When Americans are in need, Americans pull together. We are one country.”

Trump has a complicated record when it comes to the 9/11 attacks.

As a candidate and private citizen, he has praised police officers and firefighters in New York who risked their lives to save people trapped inside the World Trade Center. He told the story Monday of a man who showed similar bravery at the Pentagon on the day of the attack.

But he has also made several divisive comments about the events of that day.

During a debate last February, he appeared to blame President Bill Clinton William (Bill) Jefferson ClintonDolly Parton remembers Ginsburg: 'Her voice was soft but her message rang loud' Sunday shows preview: Justice Ginsburg dies, sparking partisan battle over vacancy before election Calls grow for Biden to expand election map in final sprint MORE for the attack because he “didn’t kill Osama bin Laden when he had the chance to kill him” and said his successor, George W. Bush, failed to do so because “he didn’t listen to the advice of the CIA.”

Trump also claimed that when the Twin Towers collapsed, “thousands and thousands of people were cheering” in New Jersey, where he said there are “large Arab populations.” There is no record of such celebrations in New Jersey. The website PolitiFact rated the claim “Pants on Fire,” denoting the most egregious falsehood.

During a phone interview with a New York television station on the day of the attack, Trump claimed the destruction of the World Trade Center made a building he owned “the tallest” in lower Manhattan.