In 1172 Murcia was conquered by the north African Almohades, the last Muslim empire to rule southern Spain, and as the forces of the Christian Reconquista gained the upper hand, was the capital of a small Muslim emirate from 1223 to 1243. By the treaty of Alcaraz, in 1243, the Christian king Ferdinand III of Castile made Murcia a protectorate, getting access to the Mediterranean sea while Murcia was protected against Granada and Aragon. The Christian population of the town became the majority as immigrants poured in from almost all parts of the Iberian Peninsula. Christian immigration was encouraged with the goal of establishing a loyal Christian base. These measures led to the Muslim popular revolt in 1264, which was quelled by James I of Aragon in 1266, conquering Murcia and bringing Aragonese and Catalan immigrants with him.