The magnetic moment is defined as a vector relating the aligning torque on the object from an externally applied magnetic field to the field vector itself. The relationship is given by[1]
oldsymbol{ au} = oldsymbol{mu} imesmathbf{B}
where oldsymbol{ au} is the torque acting on the dipole and mathbf{B} is the external magnetic field, and oldsymbol{mu} is the magnetic moment.
This definition is based on how one would measure the magnetic moment, in principle, of an unknown sample.