Secret 500-year-old letters sent by King Ferdinand II of Aragon to one of his military commanders have finally been deciphered.

Spain’s Army Museum called in experts from Spain’s intelligence agency, the Centro Nacional de Inteligencia (CNI), to help decipher the mysterious documents. The letters, which use a combination of 237 letter codes and 88 symbols, had baffled historians.

Ferdinand sent the letters to Gonzalo Fernández de Córdoba, known as the Great Captain, during a military campaign in Italy in the early 16th century.

Spanish newspaper ABC describes the letters as “one of the great mysteries in the history of Spain.”

One of the letters written by King Ferdinand II of Aragon to his military commander Gonzalo Fernández de Córdoba using secret code. (Credit:Duques de Maqueda)

Documents belonging to the Dukes of Maqueda, a Spanish noble house, helped experts unravel the mystery. The trove contained 16 letters from Ferdinand to de Córdoba, which were transcribed into modern text by a handwriting expert. “It was then that it was discovered that four of these letters were encrypted and the Museum put its effort into deciphering them,” explained the Army Museum in a statement translated from the Spanish.

After historians were unable to crack the codes, the Museum turned to the CNI. A small piece of text deciphered by de Córdoba at the foot of one of the documents provided a vital clue that helped the CNI team unlock the code.

Nonetheless, the BBC reports that it took the intelligence agency almost half a year to decipher the letters.

One of the letters written by King Ferdinand II of Aragon to his military commander Gonzalo Fernández de Córdoba using secret code. (Credit:Duques de Maqueda)

The Museum noted the “meticulous and detailed” instructions given to de Córdoba by King Ferdinand: In addition to directions on troop movements, the King also discusses the administration of justice and even promotes marriage between the local widows and the Spanish military in an attempt to achieve greater social integration. Ferdinand also criticizes the commander for launching diplomatic initiatives without consulting him, according to the BBC.

The king, who is known as Ferdinand the Catholic, is a major historical figure. He played a key role in the ‘Reconquista’ or ‘Reconquest’ that ended centuries of Islamic rule in the Iberian Peninsula. Ferdinand, with his wife Queen Isabelle I of Castile, also sponsored the voyage of Christopher Columbus to the New World in 1492.

LONG-LOST ‘NIGERIAN MONA LISA,’ VALUED AT OVER $280G, FOUND IN ‘MODEST’ NORTH LONDON APARTMENT

The monarchs also laid the foundations for the unification of Spain when their two kingdoms were combined in the 15th century. Thanks to his marriage, Ferdinand became King of Castile following Isabelle’s coronation as Queen of Castile in 1474. He also became King of Aragon on the death of his father in 1479.

Now that the secret code has been unlocked, more letters could be deciphered, The Independent reports.

Modern techniques are also being used elsewhere to unlock the secrets of other centuries-old documents. Researchers in Canada, for example, recently said that they had harnessed artificial intelligence to decode a mysterious 15th-century manuscript. Discovered in the 19thcentury, the Voynich manuscript uses “alien” characters that have long puzzled cryptographers and historians.