They are both Romance languages, meaning they evolved from Vulgar Latin, the language spoken by the common people of the Roman Empire.
While the exact timeline of their evolution is complex, both languages began to diverge from Latin around the 9th and 10th centuries AD. They developed independently in different regions of the Iberian Peninsula, with Spanish evolving mainly in the north and Portuguese in the west.
Therefore, it's not accurate to say that one is older than the other. They are sister languages with a shared ancestor and have developed in parallel for centuries.