The United States Geological Survey said the quake struck early Tuesday evening local time at a depth of about 237 km.
Earthquakes at shallower depths are felt more strongly at the surface.
The jolt was centred at sea, 153 km west of Neiafu, the second largest town in the island nation. There were no immediate reports of damage.
Tonga's National Disaster Risk Management Office warned all in the low-lying island nation to move immediately to higher ground or inland.
People should avoid beaches, shorelines, and low-lying coastal areas until an all-clear was given, said a post on the office's Facebook page.
The USGS did not issue a tsunami warning for the region, and the Pacific Tsunami Warning Centre in Hawaii said in a bulletin that there was no tsunami threat because the quake was "located too deep inside the earth.
" Tonga is an archipelago in Polynesia made up of 171 islands with just over 100,000 people, most of whom live on the main island of Tongatapu.
Tuesday's quake was centred nearer to the Vava'u island group.