There were no immediate reports of casualties or major damage in the area, which has been rocked by strong quakes in the past.
"I was asleep with my family when suddenly the house started to shake," said an AFP reporter in Ambon.
"The quake was really strong. We ran from our house and saw the neighbours fleeing too. Everybody was panicking."
Multiple aftershocks have rippled across the area, he added.
Initial reports said the quake struck offshore, but later analysis found it hit onshore, raising the potential for damage, according to Indonesia's national disaster mitigation agency.
Local disaster agency head Oral Sem Wilar called for calm.
"People were panicking and started to evacuate in some places, but we are trying to tell them there's no need to panic because there's no tsunami threat," he told AFP.
"We are still checking on damage and any casualties."
Indonesia experiences frequent seismic and volcanic activity due to its position on the Pacific "Ring of Fire", where tectonic plates collide.
In August, five people died and several were injured after a powerful undersea earthquake rocked Indonesia's heavily populated Java island.
Last year, a 7.5-magnitude quake and a subsequent tsunami in Palu on Sulawesi island left more than 4,300 people dead or missing.
The force of the impact saw entire neighbourhoods levelled by liquefaction -- a process where the ground starts behaving like a liquid and swallows up the earth like quicksand.
Nearly 60,000 people are still living in makeshift accommodation nearly a year after the double disaster, the Red Cross said this week.
On Boxing Day 2004, a devastating 9.1-magnitude earthquake struck off the coast of Sumatra and triggered a tsunami that killed 220,000 throughout the region, including around 170,000 in Indonesia. —AFP