During the roman period, this town was called Myrtilis and the Muslims changed its name to Martula. During the Muslim period in Mertola, a castle stood here. It is said that main door had a beautiful arch to enter the castle. Everything of the Muslim castle has lost but apart from few bases of the towers.
During the 10th-11th centuries, this area was used as a living space. In the early 12th century, this part of the town gained military importance and castle was used to serve its purpose as military use only. In 1238, the castle was taken from the Moors by King Sancho II. A reconstruction was carried out by the knights of the Order of Saint James of the Sword after the town was taken by the Christians. Between 1240-1245 and 1316, this town became the seat of the Military Order of Santiago.