The tremor was registered at 22:59 GMT on Wednesday, 48 kilometers (about 30 miles) northwest of the town of Minas de Marcona. The epicenter of the earthquake was located at a depth of 30 kilometers.
There are no reports of any damage or victims caused by the earthquake.
Peru is located in a seismically active zone known as the Ring of Fire, which is regularly affected by powerful earthquakes and eruptions. The country lies along the border between the South American and Nazca tectonic plates, whose movement causes high seismic activity.