The Iberian peninsula prior to the XVI century was anything but a unified territory. Not only was there a substantial Muslim presence in the southern lands, there was also great diversity among the Christian kingdoms settled on the region, which more often than not were antagonistic towards each other. Hence, mapping the development of literature in the Spanish Middle Ages is, by necessity, a fragmentary affair.
Contrary to popular belief, high-brow culture was neither disregarded nor unimportant during the Middle Ages - certainly not during the High Middle Ages, nor, for that matter, during the latter half of the Early Middle Ages. The difference, however, lies in the purpose, target and divulgation of such culture. In other words, the society of the early days of the second millennium was conceived and structured in a drastically different way.
Deeply religious and fundamentally segregated, medieval society was designed to secure the greatest possible standard for its leading elements, which were, in that order and in quick succession, God and the ruler. Consequently, it was regarded as a great privilege - a matter of collective pride - to boast the best, most powerful court, and, above all, the most pious King.
Within this context, then, it will not seem surprising that the production of art, including literature, in the Spanish Middle Ages, deals primarily with religious matters and is conceived for the entertainment of the members of the courts. Furthermore, given that medieval societies were predominantly oral, this entertainment was usually delivered verbally by a jongleur, minstrel or troubadour.
The first example of a written literary text in what later became Spanish (the language spoken in the region of Castile) is the epic poem Cantar de mio Cid, dated roughly around 1200. Most likely a written transcription of one of the versions of the feats of Rodrigo Díaz de Vivar, the tale's hero, it is evident from the tone and structure of its roughly 4000 verses that it was meant to be sung, rather than read.
The Cantar de mio Cid stands out among the epic poems of the time for its equanimous tone. Far more realistic than similar works in the French or Germanic traditions, Rodrigo Díaz often finds himself on the edge of disgrace, which later renders his triumphs all the greater. This was probably used as a literary device to raise the levels of tension among the audience - likely courtesans - prior to the denouement of the recitation.
In parallel to court entertainment, a significant phenomenon of the literature of the Spanish Middle Ages was the development of Marian literature, or texts designed to sing the praises of the Virgin Mary. The oldest written poem of this sort found to date is Miracles of Our Lady, a collection of twenty-five miracles put forward by Gonzalo de Berceo, the first properly recognisable author in Spain.
Written towards 1260, the miracles in question have a double role to play, as they are supposed to popularise the cult for the Virgin Mary while at the same time they are meant to provide a set of ideal guidelines for the behaviour of the people at large. Thus, while the nature of the narrative merits a solemn approach, the fact that it is meant to be of mass consumption sees the poet adopt a more casual, often humorous, tone.
While both the Cantar de mio Cid and the Miracles of Our Lady are written in early versions of Spanish (Castilian), the dominant languages among the nobility of the peninsula were Galician, towards the north west, and Provençal nearer to Barcelona. A good illustration of this distinction can be made from the example provided by the Castilian King, Alfonso X, whose collection of songs dedicated to the Virgin Mary, the Cantigas de Santa María, was written in Galician.
Alfonso X's reign (1252-1284) was highly refined, intellectually oriented and religiously tolerant. In this environment, he appointed a royal scriptorium in Toledo to compile and translate material in a vast range of subjects, from history to astrology, from chess to law. It seems significant, however, that all of them, except the Cantigas, were written in the Castilian dialect.
Literary production, much like the development of other artistic forms in the Spanish Middle Ages, was relatively substantial, due to the vivid cultural exchange that took place in the peninsula, and the considerable income derived by the dominant Christian monarchs from the Muslim petty kingdoms from the second half of the XI century onwards.