Spanish is also a Romance language, together with Portuguese, French, Italian and Romanian. This means that Latin, or more specifically, Vulgar Latin, is its main linguistic basis. Spanish words that come from Latin are mesa, rosa, paz, padre, madre, cabeza, cuerpo, sano, pureza, caridad, flor, mar, siervo, bueno, obra, mío, tuyo, rey, agua, cielo and many others.
Continuous contact and mutual influences between the Latin basis and other linguistic traditions led to the formation of Romance languages as we know them today. In Spanish, Iberian and Celtic influences were important in the beginning. We can also find Greek (through Latin) and Germanic roots, the latest because of Visigoths ruling the Iberian Peninsula during the sixth, seventh and part of eight centuries. They left words such as guerra, yelmo, franco, gótico and names such as Rodrigo, Roberto, Fernando, Álvaro or Rodolfo.
In 711 Arabs came to the Peninsula and defeated the Visigothic king. Different Arabic- speaking peoples dominated the Peninsula (or part of it) for almost eight centuries. This had a big impact on the Romance languages spoken in the north of the Peninsula (Galician-Portuguese, Astur-Leonese, Navarro-Aragonese, Catalonian and Castilian), most importantly on Castilian (Spanish), as this language spread more widely than others throughout the Middle Ages and had a bigger contact with Arabic.
This is why so many Spanish words have an Arabic origin. As a rule, all Spanish words beginning with the prefix "al" come from Arabic: alféizar, alondra, almohada, alacena, alcohol, albahaca, "al" meaning "the" in Arabic. But also words like arroz, azafrán, jabalí, ojalá, zanahoria, tambor, naranja, limón, aceite, azul, asesino, ajedrez or azúcar evolved from Arabic.
For many years, the so-called "Glosas Emiliacenses" were considered the first documents written in Spanish. These are commentaries and footnotes written by a monk in a Latin codex at the beginning of XI century. However, researchers have discovered that they were actually written in the Navarro-Aragonese language. The mistake is understandable, due to the similarity of these languages at that time.
It is believed nowadays that the first Castilian words were written on the "Cartularios de Valpuesta", a group of documents that are copies of manuscripts dating back to the IX century. These are written in a very late Latin and in them we can find some Castilian words.
Castilian was fully formed in the XIII century. King Alfonso X the Wise (1252-1284) greatly encouraged its use. He was the first king who ordered to write legal documents in Castilian instead of Latin, and he himself wrote numerous literary works in Castilian, giving this language great prestige.
Castilian continue to spread across the Peninsula. By the early XV century it already was the most spoken language, taking speakers from Leonese and Aragonese.