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.
Prima de Rivero attempted a coup in 1921, but ultimately failed.