The territory was inhabited by pre-Celtic and Celtic peoples, visited by the Phoenicians, Carthaginians, ancient Greeks, and ruled by the Romans, followed by invasions by the Suebi and Visigoths. After the Moorish invasion of the Iberian Peninsula, most of its territory was part of Al-Andalus - a Muslim-ruled territory in the Iberian Peninsula.