A magnitude 6.2 earthquake has rocked Afghanistan and Pakistan, sending people racing out of buildings in the two capitals.

The U.S. Geological Survey says the temblor was centered just across the border, in a remote part of Tajikistan.

Omer Mohammadi, a spokesman for Afghanistan's disaster management authority, says two small children were injured when their home collapsed.

In Islamabad and Kabul, people fled their offices and homes and recited verses from the Quran in the streets.

The two countries are prone to earthquakes.

Earlier Wednesday, a magnitude 5.1 earthquake rattled parts of eastern Pakistan, near the border with Afghanistan. That quake caused a stampede at a school in the northwestern city of Bannu, injuring at least 10 students, according to Mohammad Aslam, a local police official.