COLORADO SPRINGS, COLO: President Barack Obama defended his foreign policy legacy on Thursday and urged Americans not to embrace isolationism during a speech at the US Air Force Academy that will be his last to military graduates before leaving office.

Obama, who on Wednesday sharply attacked the policies of Republican presidential candidate Donald Trump, made more subtle references to the billionaire by noting the importance of treaties and alliances such as NATO, which Trump has questioned.

As is his custom recently, Obama did not mention Trump by name.

“We cannot turn inward. We cannot give in to isolationism, that’s a false comfort,” he said in Colorado Springs to a polite but not overly effusive crowd.

Obama urged Congress to recognise that international treaties were not a threat to US sovereignty and called on lawmakers to follow military leaders’ urging and approve the Law of the Sea Convention as Washington worries about Beijing’s tactics in the South China Sea.

“From NATO to treaties controlling nuclear weapons, treaties help keep us safe,” he said.

Alluding to the election to succeed him, Obama noted that the United States was debating its role in the world.

“Here’s a fact: the United States of America remains the most powerful nation on earth and a force for good,” he said.

Interestingly, as cadets celebrated after taking their oath during the graduation ceremony, a cadet from Pakistan held up his flag.

At the ceremony, Obama further reviewed and defended some of the controversial foreign policy accomplishments of his tenure, including the killing of al Qaeda leader Osama bin Laden, the opening of diplomatic relations with Cuba, and the securing of a nuclear agreement with Iran.

Critics have faulted Obama for not intervening more to stop the violence in Syria.

Obama said diplomacy was as important as military might and said the Syrian civil war exemplified that, requiring diplomacy that would include a transition away from Syrian President Bashar al-Assad.

“As a father, I look at Syria’s children and I see my own,” he said.

“But suggestions for deeper US military involvement in a conflict like the Syrian civil war have to be fully thought through … the only real solution to the Syrian conflict is a political solution.”

In a lighter moment Obama, who leaves office in January of next year, said he would miss Air Force One, the presidential plane that has flown him all over the world.