During the Roman period, Tarifa was known as Julia Transducta (also known as Julia Joza, or just Transducta). Tarifa name was given after the attack of Tarif ibn Malik in 710, a Berber military commander of Musa bin Nusayr.
The city was also known as the place where citizens of Zelis (near Tingis) resettled. The village of Bolonia near Tarifa was also populated in Roman times (called Baelo Claudia). Roman ruins still exist near the village today.
After the Islamic conquest of southern Spain, the city was fortified starting from the 10th century. Later Tarifa was held by the taifa of Algeciras (1031) and by that of Seville (1057), and subsequently by the Almoravids. After the latter's fall, it lived a short period under another taifa of Algeciras (1231), until becoming part of the Kingdom of Granada. In 1292 it was conquered by Sancho IV of Castile, and two years later it resisted a siege by North African Islamic troops. The town resisted another siege in 1340 from Moroccan troops, eventually leading to the Battle of Río Salado.
In 1514 it become the seat of marquisate including also Bornos, Espera and Alcalá de los Gazules. In the course of the Peninsular War, Tarifa was besieged by French troops on 20 December 1810, and again on 18 October 1811