In this paper, we study the nonlinear stability of Ekman-Hartmann type boundary layers in a rotating magnetohydrodynamics flow under a sharp spectral assumption. This generalizes the result of Desjardins et al (1999 Nonlinearity 12 181-99) obtained under a smallness assumption on a Reynolds number and the result of Rousset (2003 Arch. Rat. Mech. Anal. in press) about the stability of Ekman layers.