WASHINGTON — President Obama said on Saturday that the airstrikes and humanitarian assistance drops he ordered last week in Iraq could go on for months, preparing Americans for an extended military presence in the skies there as Iraq’s leaders try to build a new government.

“I don’t think we’re going to solve this problem in weeks,” Mr. Obama told reporters before leaving for a two-week golf-and-beach vacation on Martha’s Vineyard. “This is going to be a long-term project.”

The president repeated his insistence that his administration would not send ground troops back to Iraq after ending an unpopular, decade-long war and withdrawing the last troops in 2011. But two days after emphasizing the limited scope of the mission in a White House address, he pledged that the United States would stand with Iraq if it could form a unified and inclusive government to counter the Sunni militants who threaten its future.

“Changing that environment so that the millions of Sunnis who live in these areas feel connected to and well served by a national government, that’s a long-term process,” he said during a lengthy departure statement on the White House lawn during which he took several questions from reporters.