In the cave "Cueva de Nerja", about five kilometers from the city, evidence of human settlement from the Paleolithic Age was found.
In the village of Maro, four kilometers east of the city, remnants of the Roman settlement “Detunda” were discovered.
The Moors established first buildings a little further inland than the present city.
The first written references to the name Nerja come from the historian Almacarri de Tremecen and the Arab poet and geographer Ibn Sadí around 917, with the place name Nerja, Naricha, Narixa or Narija and the meaning "(rich) water source".
The Moors also build a small fortress on the shoreline. After the Duke of Nájera conquered the city of Vélez-Málaga in 1487, Nerja surrendered without resistance to Christian rule.
In 1509, the construction of a small fortress in the town of Nerja was completed. It was built on a cliff and did not stand at the same place as the fortress of the Moors. The fortress was designed to protect against Berber attacks. In the 16th century, many Arab-born inhabitants moved away or were expelled. This was mainly due to the resettlement of early Christians from Vizcaya, Galicia, Valencia, Seville and other parts of Andalusia, but also by the Moriscos rebellion in 1568.
In the War of Independence in 1812, during the occupation by Napoleonic troops, the British fleet destroyed the small fortress.
On December 25, 1884 a major earthquake shook large parts of the Axarquía (the eastern part of the province of Málaga) and parts of the province of Granada. The earthquake killed 900 people. In Nerja many houses were destroyed. Due to the earthquake Alfonso XII visited the city on January 20, 1885 and held a speech in the square where the former fortress stood, which already then was called "Balcón de Europa". The place became very well known. Today, you’ll find a bronze statue of Alfons XII on the square.