The epicenter of the quake, which struck at 1854 GMT, was located about 300 kilometers (185 miles) southeast of Lima, the US Geological Survey reported.
Thousands of people evacuated buildings in Lima, which has a population of 8.5 million, and other cities.
Civil defense officials said three people were slightly wounded and two adobe buildings collapsed in the city of Ica, some 250 kilometers southeast of Lima and only about 50 kilometers from the epicenter.
The quake struck at a depth of 35 kilometers, the USGS said.
On August 15, 2007, an earthquake near the same spot with a magnitude of 7.9 devastated Ica province, killing some 600 people and causing extensive damage to area buildings and infrastructure.
President Ollanta Humala urged Peruvians, especially those in Ica -- where three strong aftershocks were felt -- to stay calm.
"We have army engineering units there that will fix whatever needs to be repaired immediately," he said, speaking from a summit of regional leaders in Paraguay.
Friday's quake was felt most acutely in the coastal area around Ica, which is the provincial capital, and south of Lima.
But it was also felt in the high Andes "in cities like Cusco, Arequipa and Ayacucho, though it was less intense there," said Hernan Tavera, head of Peru's Geophysical Institute, which monitors earthquakes locally.
Some phone lines were cut, but most appeared to have been quickly restored.
Peruvian civil defense authorities said there was no threat from a tsunami.
In 2009, more than 140 earthquakes with magnitudes of 4.0 and above were felt in Peru, located on what geologists call the Pacific Ring of Fire due to its intense seismic activity.