First Melillan campaign The First Melillan campaign , also called the Melilla War or the Margallo War ( after Juan García y Margallo , the Spanish governor of Melilla whose defeat and death infuriated the Spanish public ) in Spain , was a conflict between Spain and 39 of the Rif tribes of northern Morocco , and later the Sultan of Morocco , that began in October 1893 , was openly declared November 9 , 1893 , and was resolved by the Treaty of Fez in 1894 . Historical situation . Castile captured the citadel of Melilla in 1497 . In the 19th century Spain moved into the outlying territories and began investing in their economic development . Treaties with Morocco in 1859 , 1860 , and 1861 consolidated Spain ' s growing interests . Although Spain enjoyed the compliance of the Moroccan government , tensions flared between Spanish Army patrols and the local Berber tribes that were hostile to both Spain and Morocco , and over whom the Sultan had practically no control . Rif raiding and piracy was widely reported in the Spanish press and produced the occasional sensational incident . In the early 1890s the Rif captured a Spanish merchant vessel and abducted its crew ; a small rescue expedition headed by the Spanish cruiser " Isla de Luzon " concluded that the captives had been sold into slavery . Over the summer of 1893 a period of renewed agitation by the locals enabled García y Magallo to secure the funds for the expansion of fortifications surrounding the city . Construction was pushed forward as fast as possible , the main effort being to erect new redoubt s at " Peuta de Cabiza " and " Punta Dolossos " . Siege of Melilla . After a period of escalating violence the war began in earnest on October 3 when 6 , 000 Rif warriors armed with Remington rifles descended from the mountains and attacked the city ' s garrison of 400 regular infantry . The Spaniards fought a bloody daylong battle without relief , losing 21 dead and 100 wounded , while the citizens of Melilla fled to the citadel . Although a civilian corps was organized to aid in the defence , the weight of the attackers , whose ranks were swelled by tribesmen from the hills , compelled the last of the defenders to retire to the fortress . Lacking any form of heavy weaponry , the Rif tried to take the citadel by storm , charging up the road ways and scaling the walls . Foreign observers described it as an act of gallant fury , but doomed to failure . The Spaniards held the ramparts with the bayonet and their gunfire swept the attackers from the walls . For the first time , Spanish soldiers wielded their formidable 7 mm Mauser Model 1893 ' s , made famous a few years later at the Battle of San Juan Hill . The Rif dead fell in heaps , to the number of 160 . Spanish artillery was brought forward and used to good effect to bombard the Rif assembling in neighbouring villages , but when an unlucky cannonade demolished a mosque outside of the city , the Rif effort took on the character of a jihad . Moroccans across the province , whatever their earlier sympathies , rushed to arms against Spain . By October 5 the native force numbered perhaps 12 , 000 , some reports putting its strength as high as 20 , 000 infantry and 5 , 000 cavalry . Spanish response . News of the attack brought war fever to Spain . The government dispatched the ironclad " Numancia " and two gunboat s stationed at Málaga , put the fleet on alert , and mobilized the Army of Andalusia for service abroad . Newspapers and patriotic citizens of every stripe clamoured for vengeance at whatever cost in blood or treasure . The troops mobilizing to bolster Melilla ' s garrison , initially numbering about 3 , 000 , received in many cities ceremonies and ovations from the populace as they moved to the ports . From the outset Sultan Hassan recognized Spanish grievances and reaffirmed Spain ' s right to pursue construction of field works for its own protection . However , his reluctance to cooperate in pacifying his own subjects infuriated the Spanish government and people , who found themselves committed to military operations far exceeding their modest financial resources , on account , they believed , of Moroccan negligence . The crisis . On October 4 the ironclad " Numancia " shelled several villages along the coast . An artillery detachment from Málaga arrived in Melilla that same day . For several weeks the situation stagnated . Juan García y Magallo , Governor of Melilla and commander of the Spanish forces , issued an ineffective ultimatum while the Sultan dispatched a contingent of regular troops under Baja - el - Arbi to restore the situation , without success . Skirmishes were fought at forts " Camellos " and " San Lorenzo " . When the Rif tore down the forts they ' d captured , Margallo deployed small parties of infantry and workmen to throw up new earthworks at forts " Cabrerizas " and " Rostro Gordo " , under cover of the Spanish batteries . On October 22 the gunboat " Conde de Venadito " steamed to the mouth of the Ouro , anchored there , and turned her Hotchkiss gun s on the Rif . The ship hurled 31 shells at the Rif trenches and returned to Melilla ' s harbour without sustaining any damage . 5 , 000 Rifians in turn made a heavy attack on the heights of " Sidi Guariach " on October 27 and , despite again running afoul the guns of the " Venadito " and the Spanish batteries , drove General Margallo and General Ortego back into the citadel and seized their half - finished field works . Margallo ' s sortie . To dislodge the Rifians from the works near " Cabrerizas " and " Rostro Gordo " Margallo rode out on October 28 at the head of a column of 2 , 000 men . The Rifians in the trenches numbered about 3 , 000 men ; both sides fought with courage but the Rif warriors held the line while their main body flocked 6 , 000 reinforcements to the battle . With this numerical superiority the Rif fighters extended their line in an attempt to envelop Margallo ' s Spaniards . The general , thinking he saw the enemy centre weaken , led a charge against the Rifian trenches and was thrown back with heavy losses . Margallo sounded a retreat . He was shot dead moments later and his detachment collapsed . The Spanish Army admitted to at least 70 men killed and 122 wounded that day ; actual losses were probably much higher . Only General Ortega ' s rearguard actions kept the retreat from becoming a rout . News of the disaster , coupled with Ortega ' s telegram s , convinced the Cabinet to send out an additional three regiments of cavalry and four battalion s of infantry that day . The next morning , October 29 , Ortega led 3 , 000 men out of " Cabrerizas " and swept the Rifians from their ruined trenches . Among the survivors of Margallo ' s last sortie was a young Lieutenant named Miguel Primo de Rivera . Army investigations later revealed that Margallo had made a small fortune embezzling guns and materiel from the army and selling them for profit to the locals . Ironically , the Rif warriors may have shot him using the firearms that he had sold to them . Stalemate . Early November found the besieged locked in a desperate struggle for survival . Large Rif forces held the beaches , frustrating the Spanish Navy ' s efforts to disembark horses , troops , and supplies . The Rif expanded their trenches around the city and set up fortified camps , blocking off all communication between the citadel and the outlying forts and destroying the roads between them . Only the desperate fighting of nighttime sorties kept the outposts supplied with water , rations , and munitions . Still the defenders held out and heavy fire from the fortress checked Rif advances and kept the town clear of invaders . Spanish retaliation often took gruesome turns : convicts and penal labour ers were assembled into search and destroy units led by army officers and crept out into the night to ambush Rif patrols . These units both terrified the Rif and captured the imagination of the foreign press with their conspicuous courage and brutality . At the various forts activity continued without pause : the defenders had no lack of building materials , engineers , and manual labourers and managed to continue constructing their redoubts even while under siege . The Spanish lost 12 officers and 100 men during the month , while Rif losses were fixed at 500 dead , mostly from bombardment . Relief and peace . With the arrival of the armoured cruiser s " Alfonso XII " and " Isla de Luzon " , Spain began to apply its naval power to full effect , subjecting the Rif to incessant and untiring bombardment from the coast . On November 6 Spain ' s naval guns forced a request for parley from the shot - torn Rif . When the Rif proved unwilling to surrender these cannonades were repeated nightly by searchlight , marking the first battlefield use of the device . On the Peninsula Spain ' s sometimes lethargic military machinery , brought to a high pitch of activity by Margallo ' s military reverses , began to produce visible results , and General Macias , Margallo ' s successor , received by the middle of the month sufficient forces to keep the Rif in check and rebuild Melilla ' s outer defences . General Martínez - Campos steamed for Melilla on November 27 with 7 , 000 reinforcements , bringing the total men committed to the war to two Army Corps . In April 1894 Martínez de Campos , in addition to his military command , was appointed Ambassador to Morocco and negotiated peace directly with the Sultan . Aftermath . European Powers watched Spain ' s campaigns against the Rif closely . France , seeking an ally for her own designs on the region , encouraged Spanish territorial expansion at the expense of Morocco . Madrid , however , being largely uninterested in an African empire and cautious not to offend the United Kingdom ( which viewed any acquisition of territory along the Straits of Gibraltar with alarm ) , demanded only token territorial concessions from the Sultan . This did not discourage French ambitions , however , and in 1912 the Treaty of Fez divided Morocco into French and Spanish protectorate s . As a result of the war Melilla was granted its own branch of the " Guardia Civil " , Spain ' s Gendarmerie .