WASHINGTON -  US media has reported that President Barack Obama admitted in an address on Tuesday that the United States could not wipe out the Taliban militant group in Afghanistan, but could help it end years of instability by supporting the government in Kabul.

In his final speech on national security as commander in chief of the US Armed forces Obama said despite U.S efforts, the situation in the war-plagued country remains unstable, the president said.

“I don’t want to paint too rosy a picture. The situation in Afghanistan is still tough. War has been a part of life in Afghanistan for over 30 years. The U.S cannot eliminate the Taliban or end violence in that country,” Obama said before U.S soldiers at MacDill Air Force Base in Florida.

“But what we can do is deny al-Qaeda a safe haven and what we can do is support the Afghans who want a better future, which is why we ave not only worked with our military but we backed a unity government in Kabul,” he added.

Barack Obama defended his efforts to fight terrorism at home and abroad in his final major speech on national security before leaving office. Obama’s speech comes just six weeks before he turns over the keys of the White House to Donald Trump, who has pledged to reverse course on many of his policies.

“Adhering to the rule of law is not a weakness,” Obama said during his speech in Tampa, Florida, alluding to Trump’s tough talk on terrorism that helped propel him to victory last month. “In the long term, it is our greatest strength.”

Obama warned that terrorist groups want to “scare us into changing the nature of who we are and our democracy.” But he said the only way they can “destroy our way of life” is “if we lose track of who we are and the values that this nation was founded upon.”

The president spoke at MacDill Air Force Base in Tampa, home to US Central Command and Special Operations Command. Those groups have been crucial to Obama’s fight against groups like al-Qaeda and the Islamic State in Iraq and Syria (ISIS).

Obama insisted his approach of relying on special operators and “a network of partners,” which include Western allies and local fighters, is “breaking the back of” ISIS.  Instead of launching a large-scale ground war, the president argued his campaign “has been relentless, it has been sustainable, it has been multilateral.”

Obama called on his successor to complete the process of closing the detention center at Guantanamo Bay and maintain his administration’s ban on torture, both areas where Trump has indicated he’ll change course.

On the torture ban, Obama said no adviser ever “told me that doing so has cost us good intelligence.”

And he cautioned against re-framing the terrorist fight as a conflict with Islam, as Trump and some of his advisers have done.  “If we act like this is a war between the United States and Islam, we’re not just going to lose more Americans to terrorist attacks,” Obama said. “But we’ll also lose sight of the very principles we claim to defend.”

Obama acknowledged that the situation in Afghanistan is not perfect, but that the fight is now almost entirely being waged by Afghan forces, not by Americans. White House aides say Obama had been planning the speech for months, but the stakes rose when Trump won the election last month.

Obama on Tuesday sought to outline a battle plan against terrorist groups for an incoming commander in chief with no government or military experience.

His remarks could also been seen as an attempt to pressure Trump to abandon some of his strident positions on foreign policy and national security, but it’s unclear whether his words will persuade Trump to change course.

The two men have spoken privately a number of times since the election, and Trump has indicated openness to Obama’s arguments on healthcare and climate change.

But Trump has pledged a far more aggressive approach than Obama on terrorism.

Trump has called for the use of torture against terror suspects, advocated a ban on Muslim immigration and questioned the United States’ involvement in NATO, although he’s tweaked some of those positions after his election.

He also said he would resume placing terror suspects at Guantanamo, which Obama called a “blot on our national honour.”

Retired Marine Gen James Mattis, Trump’s pick for defence secretary, is expected to support sending more troops to the Middle East to fight terrorist groups.

Throughout the campaign, Trump often touted his support from military service members, and pre-election polls showed him with an advantage over Hillary Clinton, the Democratic nominee.

Aside from Obama’s criticism of Congress for not passing a war authorization against ISIS, the president received only tepid applause for most of his remarks from the men and women in uniform at the base on Tuesday.

The White House cast the speech as a chance to sum up Obama’s national security agenda after eight years in the White House.

Obama touted his successes, including winding down the Iraq and Afghanistan wars and authorizing the mission to kill Osama bin Laden. But he also lamented the fact he’ll become the first president to serve two full terms on a wartime footing.

Critics have said Obama has not done enough to counter the threat ISIS poses to the homeland or to curtail the civil war in Syria.

Unlike previous wars, Obama warned the fight against terrorism will be a long one that might not produce “a clearly defined victory.”

“So rather than offer false promises - that we can eliminate terrorism by dropping more bombs, or deploying more and more troops or fencing ourselves offer the rest of the world - we have to take a long view of the terrorist threat,” Obama said.

“We have to pursue a smart strategy that can be sustained.”

Obama’s speech drew criticism from Republicans, including his 2008 presidential campaign opponent, Senator John McCain of Arizona. “President Obama’s speech was nothing more than a feeble attempt to evade the harsh judgment of history,” Mr McCain said. “But to the American people, our emboldened enemies, and our dispirited allies, his legacy on counterterrorism is unmistakably clear: a disastrous withdrawal from Iraq, the terrorist rampage of ISIL, an indecisive approach to the war in Afghanistan that has empowered the Taliban, and an indifferent approach to the carnage in Syria on which our terrorist enemies have thrived. No rhetorical conceit will alter history’s verdict.”