There is evidence of human habitation in the area since prehistoric times and there are significant Iberian ruins on the hillsides nearby. In the 4th century BC it was a Greek colony of Marseille or Empúries, being mentioned by Strabo as Hemeroscòpion. It was an ally of Rome during the Punic Wars, and later was absorbed into the Roman Empire under the name of Dianum. In the 1st century BC Quintus Sertorius established a Roman naval base here.
In 636-696, during the Visigothic Kingdom of Iberia, it was the seat of a bishop from Toledo. After the Muslim conquest of Iberia and the dissolution of the Caliphate of Córdoba, Dénia (known as Deniyya which means lowland) became the capital of a taifa kingdom that reigned over part of the Valencian coast and Ibiza. TheSlavic Muslim slaves, saqaliba led by Muyahid ibn Yusuf ibn Ali their leader, who could take profit from the progressive crumbling of the Caliphate's superstructure to gain control over the province of Dénia. The Saqaliba managed to free themselves and run the Taifa which extended its reach as far as the islands of Majorca and its capitol Medina Mayurqa. The Saqaliba Taifa lost its independence in 1076, when it was captured by Ahmad al-Muqtadir, lord of Zaragoza, under which it remained until the Almoravid invasion in 1091. The Muslim Arabs originally built the castle fortress, and the French, who occupied the city for four years during the War of the Spanish Succession, re-built it in the early 19th century.
The town was captured by the Christians in 1244. This caused a decline for the city, which remained nearly uninhabited after the exile of most of the Muslim population. It was later repopulated by the Valencian government. Created a fief in 1298, it was held by the de Sandoval family from 1431, although the city itself was returned to Aragonese crown in 1455. A marquisate from 1487, Dénia gained many privileges thanks to Francisco Gómez de