The quake hit 37 kilometers (23 miles) north-northeast of the city of Mansehra, Khyber Pakhtunkhwa province, at a depth of 28.9 kilometers, the US Geological Survey said.
It was followed by two aftershocks with a magnitude of 3.2 and 4, Pakistan’s meteorological department said.
The quake was also felt in surrounding towns and districts, including the capital Islamabad and in parts of Pakistan-administered Kashmir.
Zarif Ul Maani, a senior official in Batgram district neighboring Mansehra told AFP that at least five people were injured and taken to hospital.
Two houses were also damaged, Maani said.
Pakistan straddles part of the boundary where the Indian and Eurasian tectonic plates meet, making the country susceptible to earthquakes.
It was hit by a 7.6-magnitude quake on October 8, 2005 that killed more than 73,000 people and left about 3.5 million homeless, mainly in Pakistan-controlled Kashmir.
A 7.7-magnitude earthquake devastated several areas in southwestern Baluchistan province in September 2013, killing at least 370 people and leaving 100,000 homeless.