Many people don’t realize that His Majesty King Juan Carlos I has many titles other than “King of Spain.” As Wikipedia explains:
The constitution allows for the use of other historic titles pertaining to the Spanish monarchy, without specifying them.
A decree promulgated 6 November 1987 at the Council of Ministers regulates the titles further, and on that basis the monarch of Spain has a right to use (“may use”) those other titles appertaining to the Crown.
Contrary to some belief, the long titular that contains the list of over 20 kingdoms is not in state use, nor is it used in Spanish diplomacy.
In fact, it has never been in use in that form, as “Spain” was never a part of the list in pre-1837 era when the long list was officially used. This feudal style was last used officially in 1836, in the titulary of Isabella II of Spain before she became constitutional Queen.
Therefore, the King’s titles include King of Jerusalem, of Castile, of León, of Aragón, of the Two Sicilies, of Navarre, of Granada, of Toledo, of Valencia, of Galicia, of Majorca, of Seville, of Sardinia, of Córdoba, of Corsica, of Murcia, of Menorca, of Jaén, of Gibraltar, of the Canary Islands, of the East and West Indies, and of the Islands and Mainland of the Ocean Sea.

Also, Archduke of Austria, Duke of Burgundy, of Brabant, of Milan, of New Patras, Count of Habsburg, of Flanders, of Tyrol, of Roussillon and of Barcelona.
Plus, Lord of Biscay and of Molina.
It is important to remember that modern Spain is a combination of several Kingdoms. Plus, the Spanish Monarch has at different times in history controlled land and interests well beyond the Iberian Peninsula. The King of Spain was once also Holy Roman Emperor.
However, it is the Duchess of Alba who has the most aristocratic titles. Media reports indicate that Cayetana Fitz-James has 44 noble titles and 150 hereditary ones.

King of Jerusalem? How did that happen?
In short it’s because of the Crusades. It’s one of the titles that belongs to the Spanish crown but has little practical value.
Of course! The Kingdom of Jerusalem! Thanks for reminding me.