Perhaps this may help.
In short. In Classical times Spain was a province of the Roman Empire. At the beginning of the Middle ages it was invaded by several barbarian groups that formed new governments, particularly the Vandals.
During the 8th century the Arabs invaded the country and formed a Muslim country called Al-Andalus. The northern regions remained Christian.
The Christian recovered Spain in a long war that started with the invasion and ended with the fall of Granada in 1492.
Pinguin