  We develop the general theory of spinning particles with electric and
magnetic dipole moments moving in arbitrary electromagnetic, inertial and
gravitational fields. Both the quantum-mechanical and classical dynamics is
investigated. We start from the covariant Dirac equation extended to a
spin-${\frac 12}$ fermion with anomalous magnetic and electric dipole moments
and then perform the relativistic Foldy-Wouthuysen transformation. This
transformation allows us to obtain the quantum-mechanical equations of motion
for the physical operators in the Schr\"odinger form and to establish the
classical limit of relativistic quantum mechanics. The results obtained are
then compared to the general classical description of the spinning particle
interacting with electromagnetic, inertial and gravitational fields. The
complete agreement between the quantum mechanics and the classical theory is
proven in the general case. As an application of the results obtained, we
consider the dynamics of a spinning particle in a gravitational wave and
analyze the prospects of using the magnetic resonance setup to find possible
manifestations of the gravitational wave on spin.
