Nine people were injured in the quake, which was felt in a few towns and prompted people to flee their homes, BMKG chief Dwikorita Karnawati told reporters.
Five houses were damaged and 53 aftershocks were recorded after the quake was first felt at 2:28 a.m. (1928 GMT), she said, adding there was no tsunami risk but warning of potential landslides in hilly areas.
Indonesia suffers frequent earthquakes, straddling the “Pacific Ring of Fire”, a seismically active zone where different plates of the earth’s crust meet.
The fault along Sumatra island can be particularly active and dangerous. In 2004, a massive 9.1 magnitude quake and a tsunami off the northern tip of Sumatra killed 226,000 people in Indonesia, Sri Lanka, India, Thailand and nine other countries.