WASHINGTON — Speaking at West Point in May, President Obama laid out a blueprint for fighting terrorism that relies less on American soldiers, like the cadets in his audience that day, and more on training troops in countries where those threats had taken root.

But this indirect approach, intended to avoid costly, bloody wars like the one the United States waged in Iraq, immediately collided with reality when a lethal jihadi insurgency swept across the same Iraqi battlefields where thousands of Americans had lost their lives.

The seizing of large parts of Iraq by Sunni militants — an offensive hastened by the collapse of the American-trained Iraqi Army — stunned the White House and has laid bare the limitations of a policy that depends on the cooperation of often balky and overmatched partners.

While the militants from ISIS have moved swiftly to establish a caliphate from eastern Syria to central Iraq, the White House is struggling to repel them with measures that administration officials concede will take months or longer to be effective.