ISLAMABAD (AP) — A 6.5-magnitude earthquake rocked much of Pakistan and Afghanistan on Tuesday, sending panicked residents fleeing their homes and offices and scaring people in remote villages. At least nine people have been killed in Pakistan and two in Afghanistan, officials said Wednesday.

More than 200 people were taken to hospitals in the Swat Valley and other parts of Pakistan’s northwestern Khyber Pakhtunkhwa province region in shock, said Bilal Faizi, a spokesman for Pakistan’s emergency services.

“These terrified people collapsed, and some of them collapsed from the shock of the earthquake,” he said. Faizi said most were later released from the hospital.

Faizi and other officials said nine people were killed when roofs collapsed in various parts of northwestern Pakistan. Dozens of people were injured in the quake, which was centered in Afghanistan and was also felt along the border with Tajikistan. The earthquake triggered landslides in some of the mountainous areas, disrupting traffic.

The nine people who died in northwest Pakistan included five men, two women and two children.

Taimoor Khan, spokesman for the northwest provincial disaster management authority, said at least 19 mud-brick houses had collapsed in remote areas. “We are still collecting data on the damage,” he said.

Powerful tremors caused many people to flee their homes and offices in Pakistan’s capital Islamabad, some reciting verses from the Koran, Islam’s holy book. Media reports suggested that cracks had appeared in some apartment buildings in the city.

In Afghanistan, Sharafat Zaman Amar, a Taliban-appointed spokesman for the Ministry of Public Health, said at least two people were killed and about 20 wounded.

“Unfortunately, there could be more casualties because the earthquake was very powerful in most of the country,” Zaman Amar said.

The scene was repeated in Kabul and other parts of Afghanistan.

“The earthquake was so strong and terrifying that we thought houses were collapsing on us, people were screaming and shocked,” said Shafiullah Azimi, a Kabul resident.

Aziz Ahmad, 45, another Kabul resident, said he and his neighbors stayed out of their homes for hours in fear of aftershocks.

“In my life, this was the first time I experienced such a powerful earthquake, everyone was terrified,” he said.

The US Geological Survey said the epicenter of the 6.5-magnitude quake was located 25 miles south-southeast of Jurm in Afghanistan’s Hindukush mountainous region, bordering Pakistan and Tajikistan. The quake struck 116 miles below the Earth’s surface, causing it to be felt over a wide area.

Khurram Shahzad, a resident of Pakistan’s military town of Rawalpindi, said he was having dinner with his family at a restaurant when the walls began to shake.

“I quickly thought it was big, we left the restaurant and we went out,” he said by phone. She said that she saw hundreds of people standing in the streets.

Pakistani Prime Minister Shahbaz Sharif said in a statement that he asked disaster management officials to remain vigilant to handle any situation.

The region is prone to violent seismic upheavals. A 7.6 magnitude earthquake in 2005 killed thousands of people in Pakistan and Kashmir.

Last year, in south-eastern Afghanistan, a powerful earthquake struck a rugged, mountainous region, crushing stone and adobe houses. Afghanistan’s Taliban rulers put the total death toll from the quake at 1,150, with hundreds more injured, while the UN has offered a lower estimate of 770.

The latest earthquake hit Pakistan as it struggles to recover from devastating floods last summer that killed 1,739 people. The Swat valley in northwest Pakistan was one of the areas affected by flooding made worse by climate change.