The US Geological Survey says the quake struck at a depth of 10 kilometres this morning, with its epicentre located about 54 kilometres east of Kota Kinabalu, capital of the Malaysian state of Sabah.
No tsunami warning was issued, and there were no initial reports of major damage or casualties.
But social media users uploaded photos showing damaged roads, shattered storefront windows, cracked walls and floors, and rooms strewn with debris flung from shelves.
The state's minister for tourism and the environment says rescue operations are underway at Mt Kinabalu with reports of climbers trapped and injured.