Although modern man did not arrive into the Iberian Peninsular until around 40,000 BCE, from the South of France, the area has a long and debateable history of inhabitation by early man.
Evidence shows inhabitation by "homo erectus" from a million years BCE, and Neanderthal man since 200,000 BCE, and both having ruled the world for far longer than modern man has, eventually faded into extinction, leaving the way clear for the start of the end.
The Peninsular has always been a melting pot, standing as it does central to the cultures of the eastern Mediterranean, Europe, and Africa, and the inhabitants developed as a seafaring "nation" as early as 5000-3000 BCE, reaching distant shores.
Subsequent trading, invasions and migrations of Phoenicians, Celts, Greeks, Carthaginians and Romans all left their stamp on the developing nation, followed later by the Vandals, Goths and Arabs.
The many small states that developed under warlords by the middle ages, were gradually unified into what we know as Spain today, with of course the exception of Portugal, although there are several areas which still object strongly to the unification including the Basques, Catalonia, and the Canary Islands.