The anthem first appeared in a book of military bugle calls dating from 1761, known as the “Marcha Granadera”. In 1770 King Carlos III declared it as the official “honour march”, and was played at events attended by the royal family. It was then soon known as the “Marcha Real”. The origin of the melody is in dispute. Researchers have claimed that it originated in parts of Europe outside Spain (such as France and Germany), and indeed the music is not typical of Spanish music.
In 1870, there was a contest held to have a new national anthem, but no winner was declared and the “Marcha Real” (as it is commonly known) remained as Spain’s anthem. After the anthem was replaced by the Republican forces in the Spanish Civil War with “Himno Riego“, the victorious monarchist forces restored the “Marcha Real” by a decree from General Franco in July 1942. Upon the restoration of the monarchy after Franco’s death in 1975, the name of the anthem was changed to simply “Himno Nacional Español”, perhaps to stress that the anthem belonged to the entire nation, rather than just the king. In 1997 the royal family issued a decree regulating the official use of the anthem. Among other things, a long version and a short version (without the section repeats) were decreed, the long version is to be used for the King, the short version is for the Prince, the Prime Minister, or to be performed for sporting events or other events of the like.
There have been many attempts to compose lyrics for the anthem; one set of lyrics by Eduardo Marquina was often heard during the reign of Alphons XIII (1886-1931), and lyrics which were common during Franco’s dictatorship (1939-1975); neither of these were official in their respective time periods, and have not been made official since then, due to their association with the dictatorships of Primo de Rivera and Franco respectively.