spanish north-west africa?

hey i'm wonder if its possible or plausible for spain sometime between 1820-1900 to gain either moroccoo, algieria or both as a colony & what would they have to do to acheve this
 
During the last years of the XVIII and the first years of XIX centur, there was a spanish "secret agent" (Domenec Badía, aka Ali-Bey) that plotted with a Moroccan claimant to the throne offering spanish aid for him in exchange for northern Morocco. However Charles IV thought that would be backstabbing another king (Morocco's) and rejected the offer. But what if...
 
I'm sure it's entirely possible. It would be an expensivr endeavour though. The Spanish awould have a hard time later on if they held onto Morocco, what with Cuba getting restles sin the latter half of the century, and a drain on the economy in Morocco.
 
During most of the 19th century the British were hostile to other country seizing Morocco and thus placing forces too close to Gibraltar (or in Spain's side, on both sides of it). During the war of 1859 they intervened to ensure that Spain would not demand territory for example.

Later, France (who had had an interest in the Moroccan atlantic ports since shortly after the conquest of Algeria) tried to get Spain to agree to a partition of Morocco in order to circunvent Britain's opposition, especially coinciding with the Margallo War of 1893. However, Spain at the time was dominated by PM Cánovas del Castillo who was opposed to militarism and colonialism, and instead preferred an independent unified Morocco under Spain's influence.
 
Top