MRI scans use the fact that protons in our bod can be seen as bar magnets. We saw in this lesson that this is especially due to the magnetic dipole moment. In such an MRI scan, an external magnetic field is turned on. The protons will align with this external magnetic field. A radiofrequency pulse is applied which pushes the proton out of its alignment. Once this pulse is no longer present, the protons re-align with the external magnetic field while releasing energy which is detected by the MRI. The time it takes to realign and the released energy are different depending on the tissues in the body.
Let me know if I interpreted something incorrectly.