Denia's historical heritage has been influenced by Iberian, Greek, Roman, Islamic, Napoleonic and Christian civilizations.
It was an ally of Rome during the Punic Wars, and later was absorbed into the Roman Empire under the name of Dianium (after their goddess Diana).
After the Muslim conquest of Iberia and the dissolution of the Caliphate of Córdoba, Dénia (Arabic: دانية, Dāniyya) became the capital of a Taifa kingdom that reigned over part of the Valencian coast and Ibiza.
The saqālibah managed to free themselves and run the kingdom, which extended its reach as far as the islands of Majorca and its capital Madinah Mayurqah [es].
The saqālibah 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 Peninsular War, rebuilt it in the early 19th century.
A marquisate from 1487, Dénia gained many privileges thanks to Francisco Gómez de Sandoval y Rojas, Duke of Lerma, a favourite of Philip III of Spain.
It suffered a further period of decay after the decree of Expulsion of the Moriscos (1609), by which 25,000 people left the marquisate, leaving the local economy in a dismal state.
The city also serves as the northern terminus for a 1,000 mm (3 ft 3+3⁄8 in) metre gauge railway line through the mountains from Alicante (popularly known as the Limón Express), run by FGV.