When Fernando died without an heir, the Spanish claimed the throne through a web of intermarriages between the two royal houses.
Through marrying their children, Spanish royalty was able to maintain their claim to the throne.
The Spanish did not claim to the throne as a result of infertility amongst the royal houses.