In the 1st century, there was a settlement here known as Pupput. It was a town (now in the suburbs of Hammamet) that became a Roman colony in 2nd century. In 13th century, walls around town were built and medina of Hammamet was built in 15th century. Then it came under Spanish and Turkish rule.
In 1601 it was the object of a successful Spanish attack. At that time the Spanish name for the place was "La Mahometa".Alonso de Contreras participated and tells the story in his autobiography. Three hundred men took seven hundred prisoners, mostly women and children because most of the men in the town had fled.
On 14 August 1605 there was another Spanish attack in which Contreras also participated but this time the result was disastrous for the attackers. It was carried out by six galleys, four from Malta, six from Sicily carrying Spanish and other Christian troops. The initial taking of the town was successful as the Spanish managed to climb the walls and open the gates but then there was an unexpected call to retreat which could not be later determined where or how it originated. In the confusion the retreat was done in disorder and the Spanish were massacred at the beach by a much smaller number of Moors. There were 1200 men gathered at the beach trying to get back to their ships but the wind had changed and conditions were difficult. The leader of the expedition, Adelantado de Castilla, lost his life as he tried to swim out to the Spanish ships and as the captain in charge of his skiff fled and ignored his calls for help. That captain was later court-martialed and, when it became clear he would be sentenced to die, his own brother poisoned him. This story and more details can be found in Contreras' autobiography.
In World War II, it became one of the headquarters of general Erwin Rommel