MRI is totally different technology.
Water molecules are polar - they have a positive side and a negative side, sort of like a magnet. The oxygen in the molecule is (relatively) negatively charged, and the two hydrogen atoms are (relatively) positively charged.
By exposing a water molecule to a magnetic field, you can get it to "line up" along the magnetic field.
Humans (and other animals) are mostly water, and different tissues have different amounts of water. So, in theory, if you can get a magnet powerful enough, you can make ALL the water molecules in a body line up along the magnetic field. Since different tissues have different amounts of water, it's possible to use a computer to differentiate the amounts of water in each tissue - and to generate a photo.