In his last major national security speech while in the Oval Office, President Barack Obama lauded his legacy while sounding notes of caution to an incoming president that has threatened to reverse many of his policies.

The United States, Obama said is “breaking the backs” of ISIS and suggested that radically shifting strategies in fighting the rise of terrorism could upend that progress.

"We need the wisdom to see that upholding our values and adhering to the rule of law is not a weakness, in the long run it is our greatest strength,” he said. “The whole objective of these terrorists is to scare us into changing the nature of who we are and our democracy,” he added.

The president highlighted the need for tolerance and adherence to rule of law during the address at Florida's MacDill Air Force Base Monday afternoon.

“We are fighting terrorists who claim to fight on behalf of Islam,” Obama said adding that ISIS and other extremists do not speak for Muslims around the world or in America. “If we stigmatize good patriotic Muslims, that just feeds the terrorists’ narrative,” he said.

Obama highlighted his administration's efforts in the ongoing fight against ISIS, saying that since he took office the terror group “has lost more than half its territory” and recruitment was on the decline.

“We should take great pride in the progress that we’ve made over the last eight years,” he said.

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.