President Obama during a U.S. counter-terrorism strategy speech at MacDill Air Force Base Tuesday, Dec. 6, 2016, in Tampa, Fla. Chris O’Meara / AP

But the president also acknowledged that “in some form this violent extremism will be with us for years to come.”

Obama then turned to words of guidance and warnings for the future, saying the nation needs to continue to uphold its values and that “fencing ourselves from the rest of the world” would harm the U.S.’s long-term strategy.

Obama said his administration was able to gain crucial information without resorting to torture and “operating outside the law” — seemingly drawing a contrast between his style of governance and President-elect Donald Trump,

who during his campaign said “torture works” and that waterboarding was “not nearly tough enough.”

A Senate Torture report from 2014 said enhanced interrogation tactics did not help to retrieve information from prisoners.

Obama also called for the need to close Guantanamo Bay, another area where he and Trump differ.

In addition, Obama stressed the need to make sure the country’s efforts a combating terrorism do not unfairly infringe on the rights of its citizens and said his own administration had placed new restrictions on the government’s ability to conduct

surveillance on individuals.

“By maintaining these civil liberties, we sustain the confidence of the American people,” he said, adding that it makes citizens more likely to help the government.

“Protecting liberty, that’s something we do for all Americans — and not just some,” he said, drawing applause from the audience.

The president told the audience that the United States was not a country that “imposed religious freedom tests” for others or “where some citizens have to withstand greater scrutiny or carry an ID card.”

“We’re a nation that believes freedom can never be taken for granted,” he said.

The statements again appeared to reference to Trump’s comments during the campaign in which he

said he would “certainly implement” a database system for tracking Muslims in an interview in November 2015.

Trump’s transition team has since claimed that Trump never advocated for a Muslim registry.

The president also urged for the need “for the universal right to speak your mind” and the ability to “protest against authority” and live in a country where one could “criticize a president without retribution,” again drawing applause.

The president concluded by asking service members to remember America’s past and “remember what that flag stands for, for we depend on you as the heirs to that legacy.”

“It has been the greatest honor of my life to serve of your Commander in Chief, I thank you for all that you’ve done,” he said.