  We continue our study of a magnetic Schr\"odinger operator on a
two-dimensional compact Riemannian manifold in the case when the minimal value
of the module of the magnetic field is strictly positive. We analyze the case
when the magnetic field has degenerate magnetic wells. The main result of the
paper is an asymptotics of the groundstate energy of the operator in the
semiclassical limit. The upper bounds are improved in the case when we have a
localization by a miniwell effect of lowest order. These results are applied to
prove the existence of an arbitrary large number of spectral gaps in the
semiclassical limit in the corresponding periodic setting.

Spectral Theory;Analysis of PDEs