Alfonso’s father, Ferdinand III, conquered Andalusia and imposed tribute on the remaining Muslim states in Spain—Murcia and Granada. His mother, Beatrice, was granddaughter of the Holy Roman emperor Frederick I. Alfonso, already known as a scholar, became king in 1252. He had many scholars in his traveling court, and he was an active participant in their writing and editing. Some were experts on Roman law, which Alfonso hoped to make the basis of a uniform code for his lands. The court, gifts to friends, and foreign intrigue proved expensive, and Alfonso taxed heavily.

Alfonso crushed a Muslim revolt in 1252 and a revolt by nobles in 1254. Morocco, Granada, and Murcia invaded in 1264, but Alfonso won with Aragonese help and annexed Murcia. In 1272, a revolt and withdrawal to Granada by nobles forced him to confirm local privileges. In 1273 Alfonso founded and granted privileges to the Mesta, a guild of migratory shepherds.

Alfonso claimed many foreign titles, notably that of Holy Roman emperor in 1256. In 1257, bribes won him four electoral votes for emperor to three for Richard of Cornwall, but Richard, unlike Alfonso, could go to Germany. In 1275 Richard died, and Alfonso went to France to appeal to Pope Gregory X, who persuaded him to renounce his claim.

While Alfonso was in France, Morocco and Granada invaded Castile. Ferdinand, Alfonso’s eldest son, was killed in the fighting. Sancho, Alfonso’s second son, became a hero in defeating the invaders and proclaimed himself heir, disregarding Ferdinand’s sons, who were nephews of the French king. Alfonso recognized Sancho’s claim in 1278 but, under French pressure, became ambiguous in 1281. Taking advantage of grievances against Alfonso, Sancho declared himself regent. Towns and nobles rose against Alfonso, who had to take refuge in Sevilla (Seville). Some of Sancho’s followers deserted, but, after Alfonso died, Sancho took Sevilla and became King Sancho IV.

Alfonso’s court scholars wrote mostly in Castilian Spanish, which they made a literary language by regularizing the syntax and by borrowing—and defining—words for concepts not previously discussed. In their Premera crónica general, they tried to determine historical facts from chronicle, folklore, and Arabic sources. Less factual was their Gran e general estoria, a world history, with extensive translations from the Old Testament. The Tablas Alfonsíes were planetary tables, based on an Arabic source but updated by observations at Toledo 1262–72. Siete partidas was the most important law code. It was based on Roman law and contained discourses on manners and morals and an idea of the king and his people as a corporation—superior to feudal arrangements—with the king as agent of both God and the people. After Alfonso’s death, Siete partidas was proclaimed the law of all Castile and Leon in 1348, and the language of Alfonso’s court evolved into modern Castilian Spanish.