For centuries, Spain recruited foreign soldiers to its army, forming the foreign regiments (Infantería de línea extranjera) such as the Regiment of Hibernia (formed in 1709 from Irishmen who fled their own country in the wake of the Flight of the Earls and the penal laws). However, the specific unit of the Spanish Army and Spain's Rapid Reaction Force, now known as the Spanish Legion (Legión Española, La Legión), and informally known as the Tercio or the Tercios, is a 20th-century creation. It was raised in the 1920s to serve as part of Spain's Army of Africa. The unit, which was established in January 1920 as the Spanish equivalent of the French Foreign Legion, was initially known as the Tercio de Extranjeros ("Tercio of foreigners"), the name under which it began fighting in the Rif War of 1921–1926.
Although foreign recruitment spans the Spanish-speaking nations, the majority of recruits are Spaniards. Over the years, the force's name has changed from Tercio de Extranjeros to Tercio de Marruecos (when the field of operations targeted Morocco), and by the end of the Rif War it became the "Spanish Legion", with several "tercios" as sub-units.
The Legion played a major role in the Nationalist forces in the Spanish Civil War. In post-Franco Spain, the modern Legion has undertaken tours of duty in the Yugoslav Wars, Afghanistan, Iraq and Operation Libre Hidalgo UNIFIL.
The Spanish Legion was formed by royal decree of King Alfonso XIII on 28 January 1920, with the Minister of War José Villalba Riquelme stating, "With the designation of Foreigners Regiment there will be created an armed military unit, whose recruits, uniform and regulations by which they should be governed will be set by the minister of war." In the 1920s the Spanish Legion's five battalions were filled primarily by native Spaniards (since foreigners were not easy to recruit) with most of its foreign members coming from the Republic of Cuba.
Historically there had been a "Spanish Foreign Legion" which preceded the modern Legion's formation in 1920.