In Islamabad, the Pakistani capital, people ran out into the open as the earthquake rattled the city. Panic was widespread in neighborhoods with high-rises and multistory apartment blocks, and hundreds of shopkeepers and customers swarmed the main avenue in Blue Area, a commercial neighborhood. Aftershocks continued for some time, keeping many from returning to their offices and homes.

In the northern city of Peshawar, Mehreen Ali, 30, a dentist, said she was sitting in a car outside a shopping plaza when the vehicle started shaking.

“I thought the car was shaking as the driver was leaning against it,” Ms. Ali said. “Then suddenly, people started coming out of the building in front. People were staring at the building as if it was about to fall as it shook.”

In the northern valley of Swat, at least 35 people were killed, local officials said. At least 100 houses were damaged, and hospital officials said that more than 250 people had been brought in for treatment.

Landslides were reported in the mountainous Pakistani regions of Gilgit and Chitral, as boulders fell on to the roads, cutting off many areas. Damage was reported in more central parts of the country as well: In Punjab Province, at least five people were reported dead.

In Afghanistan, the country’s chief executive, Abdullah Abdullah, called an emergency meeting of senior officials to respond to the disaster. “This is the strongest earthquake that has happened in our country in recent years,” Mr. Abdullah said, warning of the possibility of aftershocks.