A Spanish official has stepped down after sparking outrage with comments that made light of the crime of rape.