The US Geological Survey says a 5.5-magnitude quake struck at 0157 local time (2127 GMT), followed by a 5.1-magnitude aftershock two hours later.
The quakes struck about 50 miles (90km) east of Kabul near the Pakistan border.
They killed 15 people, wounded 20 and destroyed 100 homes, a government spokesman told the AP news agency.
Villagers in Mir Gadkhel were scrambling through the rubble of flattened houses to recover bodies after the quake, Reuters news agency reports.
Villagers there said as many as 40 people may have been killed.
The mountains of northern Afghanistan and Pakistan are frequently hit by earthquakes.
A 7.6-magnitude earthquake that rocked north-west Pakistan in October 2005 killed 74,000 people and displaced 3.5 million.