KABUL, Afghanistan — Insurgents fired dozens of rockets at the international airport in Kabul and near the American Embassy on Wednesday as the top leaders of the Pentagon and NATO met with the Afghan president.

There was no physical threat to the president, Ashraf Ghani, or his guests, Defense Secretary Jim Mattis and the NATO secretary general, Jens Stoltenberg, the first high-profile visitors to the presidential palace since the Trump administration announced a new Afghanistan strategy a month ago.

But the rocket attack forced the airport to close temporarily, highlighted the country’s fragile security and demonstrated the insurgency’s reach in even the most fortified areas of the capital.

Both the Taliban and the Islamic State claimed responsibility for the assault. Zabiullah Mujahid, a Taliban spokesman, said the group had sought to target the aircraft that brought Mr. Mattis to Kabul.