Spanish did not originate in a single modern country. It evolved on the Iberian Peninsula (shared by Spain and Portugal) from Vulgar Latin spoken by Roman soldiers and settlers. Over centuries, it absorbed influences from:
The earliest written Spanish texts appear in the 10th–11th centuries (Glosas Emilianenses). The Kingdom of Castile's expansion spread the dialect that became modern standard Spanish.