Rif War: Spanish forces including troops from the Foreign Legion under Colonel Francisco Franco landing at Al Hoceima, Morocco.

The Rif War (Spanish: Guerra del Rif) was an armed conflict fought from 1921 to 1926 between the occupying colonialists of Spain (joined by France in 1924) and the Berber tribes of the Rif mountainous region of Morocco.

Led by Abd el-Krim, the Riffians at first inflicted several defeats on the Spanish forces by using guerrilla tactics and captured European weapons. After France's military intervention against Abd el-Krim's forces and the major landing of Spanish troops at Al Hoceima, considered the first amphibious landing in history to involve the use of tanks and aircraft, Abd el-Krim surrendered to the French and was taken into exile.In July 1909, Spanish workers constructing a rail-bridge providing access to iron mines near Melilla were attacked by Rifian tribesmen. This incident led to the summoning of reinforcements from Spain itself. A series of skirmishes over the following weeks cost the Spanish over a thousand casualties. By September, the Spanish Army had 40,000 troops in northern Morocco and had occupied the tribal regions to the south and southeast of Melilla. The military operations in Jebala, in the Moroccan west, began in 1911 with the Larache landing. Spain worked to pacify a large part of the most violent areas until 1914, a slow process of consolidation of frontiers that lasted until 1919, due to World War I. The following year, after the signing of the Treaty of Fez, the northern Moroccan area was adjudicated to Spain as a protectorate. The Riffian populations strongly resisted the Spanish, unleashing a conflict that would last for several years.

In 1921, in an attempt to consolidate control of the region, the Spanish troops suffered the catastrophic Disaster of Annual in addition to a rebellion led by Rifian leader Abd el-Krim. As a result, the Spanish retreated to a few fortified positions while Abd el-Krim ultimately created an entire independent state: the Republic of the Rif. The development of the conflict and its end coincided with the dictatorship of Primo de Rivera, who took on command of the campaign from 1924 to 1927. In addition, and after the Battle of Uarga in 1925, the French intervened in the conflict and established a joint collaboration with Spain that culminated in the Alhucemas landing, which proved a turning point. The Spanish also used chemical weapons during the conflict. By 1926, the area had been pacified; Abd-el-Krim surrendered to the French that year, and Spain gained effective control of the protectorate's territory at last.

The Rif War is still considered controversial among historians. Some see in it a harbinger of the decolonization process in North Africa. Others consider it one of the last colonial wars, as it was the decision of the Spanish to conquer the Rif – nominally part of their Moroccan protectorate but de facto independent – that catalyzed the entry of France in 1924. The Rif War left a deep memory both in Spain and in Morocco. The Riffian insurgency of the 1920s can be interpreted as a precursor to the Algerian War of Independence, which took place three decades later.