text: The colonial war in Morocco provided an almost welcome distraction , but a disastrous defeat there in 1921 led to a coup in which the general Primo de Rivera became dictator .
  
  ###
  
  Spain provided part of its army to help the Moroccan government fight against Primo de Rivera .