President Obama delivers a commencement address at the U.S. Air Force Academy in Colorado Springs on June 2. (Brennan Linsley/AP)

President Obama on Thursday defended his foreign policy and warned against a strain of isolationism that has recently taken hold in American politics.

During a commencement speech delivered at the U.S. Air Force Academy here, Obama singled out for criticism those who have suggested that the United States is in decline or that its military has grown weaker. “Here’s a fact: The United States of America remains the most powerful nation on Earth and a force for good,” he said.

The president made clear that his concerns about American overreach and his caution when it comes to deploying U.S. ground troops does not signal a hesi­ta­tion to defend the country. Beginning with al-Qaeda leader Osama bin Laden, Obama read off a list of terrorist leaders who have been killed on his watch in Pakistan, Afghanistan, Syria, Somalia, Libya and Yemen. He concluded with the death of Akhtar Mohammad Mansour, the Taliban leader killed last month in a drone strike in Pakistan.

“All gone,” he said of those he had ordered killed. “The list goes on. Because if you target America, we will find you and we will defend our nation.”

Much of his speech described U.S. global obligations and the limits of American military power. The president described the large crowds during his visit last week to Vietnam, with people lining the streets in Hanoi and waving American flags to greet his motorcade. And he spoke of the never-ending demands on American leadership in a world where terrorism, disease and climate change pose real threats.

He criticized Republicans who he said have come to view every treaty as a threat to American sovereignty, and he cautioned against calls from Donald Trump, the likely Republican presidential nominee, to renegotiate or withdraw from trade deals.

“We can not turn inward. We cannot give in to isolationism,” Obama said. “That is a false comfort.”

Obama came to office promising to end American involvement in wars in Iraq and Afghanistan, but as he nears the end of his second term, the United States is still fighting al-Qaeda and the metastasizing Islamic State in countries around the globe.

But gone are the days of large numbers of U.S. troops patrolling villages in Afghanistan and Iraq or trying to rebuild those fractured countries. Today there are fewer than 15,000 American troops in Iraq and Afghanistan, down from 180,000 when Obama took office.

The president has ordered his commanders to fight largely from the air, striking Islamic State and al-Qaeda terrorists and militants with drones and attack planes. On the ground, American forces have concentrated on training and advising local forces. In some cases, especially when American lives are threatened, he has ordered commandos to carry out raids.

The strategy has produced mixed results. American military power has helped local Iraqi army forces and Syrian rebels take back ground from Islamic State fighters, but the small contingent of advisers has not been able to prevent a humanitarian catastrophe on the ground or address the political grievances driving the conflict.

Obama described the suffering in Iraq and Syria as “heart-rending” and “gut-wrenching.”

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

But he said that deploying large numbers of U.S. ground troops to establish safe zones or to try to stop the killing would not be effective or in the Unites States’ interests. He told the Air Force cadets that as military leaders they needed to be both “hardheaded” about the limits of American power and “big-hearted” about the suffering in the world.

“Our foreign policy has to be strong,” he said, “but it also has to be smart.”