The quake hit near Arawa in Papua New Guinea in the South Pacific at a depth of 167 kilometers (103 miles), the U.S. Geological Survey said.
There are no immediate reports of casualties or damage.
The countries are located in the Pacific's geologically active "Ring of Fire."