The town was finally taken from the last Muslim king Ibn Afan by Paio Peres Correia, Grand-Master of the Order of Santiago in 1242, after the Alentejo and most of the coast had already fallen in 1238.