President Ollanta Humala urged Peruvians, especially those in Ica where 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.
The earthquake 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 mountain ranges "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 defence authorities said there was no immediate 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.
AAP