MRI scanners produce a strong magnetic field that forces protons in the human body to align with it. A radio frequency current is then pulsed through the patient which stimulates these protons, causing them to spin out of equilibrium and strain against the pull of the magnetic field.
https://securescanners.com/how-do-mri-scans-work/