Febri Erizon, local government secretary in Padang Panjang town, near the epicentre, said residents panicked when the quake struck at 21:44 (1444 GMT) on Monday night.
"It was a really strong quake, we all felt it. It was unbelievable," Erizon said by telephone from Padang Panjang, 900km northwest of Jakarta.
He said four people had died, while eight were injured. About 30 homes were damaged. Associated Press news agency reported five people had been killed and 60 homes damaged.
Residents panicked and fled their homes staying outside overnight for fear their homes might collapse due to aftershocks.
But there were no reports of aftershocks.
'Ring of Fire'
The Meteorology and Geophysics Agency in Jakarta said the quake was felt across a wide area, including Bukit Tinggi town, a hill resort popular with foreign backpackers.
Officials said there were no reports foreigners had been hurt.
Indonesia, the world's largest archipelago nation, is prone to earthquakes because of its location on the so-called Pacific "Ring of Fire" - an arc of volcanic and seismic activity partly encircling the Pacific Basin.
Earlier this month, an earthquake in West Papua province with an estimated magnitude of 6.8 killed 36 people and injured more than 100.