WASHINGTON — President Obama on Wednesday authorized a major expansion of the military campaign against rampaging Sunni militants in the Middle East, including American airstrikes in Syria and the deployment of 475 more military advisers to Iraq. But he sought to dispel fears that the United States was embarking on a repeat of the wars in Iraq and Afghanistan.

In a speech to the nation from the State Floor of the White House, Mr. Obama said the United States was recruiting a global coalition to “degrade and ultimately destroy” the militants, known as the Islamic State in Iraq and Syria. He warned that “eradicating a cancer” like ISIS was a long-term challenge that would put some American troops at risk.

“We will hunt down terrorists who threaten our country, wherever they are,” Mr. Obama declared in a 14-minute address. “That means I will not hesitate to take action against ISIL in Syria, as well as Iraq,” he added, using an alternative name for ISIS. “This is a core principle of my presidency: If you threaten America, you will find no safe haven.”