People have lived in Spain's central meseta for thousands of years. In the late ninth century, with the arrival of the Moors from Northern Africa, an Arab town began to take shape in what is now modern Madrid. The Moors built a castle (alcazar) on a hill overlooking the Manzanares River to protect their newly acquired territories. Residents followed the military and settled in the area. The Moors developed an intricate irrigation system, and agriculture bloomed. During the early stages of the Christian "Reconquest" of the Iberian Peninsula, Madrid was attacked by King Ramiro II of León in 932. The Moors restored the town but remained under siege.