While they share a common ancestor, neither language came "first". They developed in parallel, evolving independently from Vulgar Latin in different regions of the Iberian Peninsula.
* Spanish originated in the northern and central regions of the peninsula, where it was influenced by the languages spoken by the local inhabitants (Celtiberian, Basque, Arabic, etc.).
* Portuguese originated in the southwestern region of the peninsula, where it was influenced by Galician and other regional dialects.
Therefore, it's more accurate to say that both Spanish and Portuguese emerged around the same time, from the same root, but evolved in different directions.