As no one has given a serious answer and
wiki does not quite have it correct I will give a quick summary (an inadequate one without reading wiki on MRI). I will emphise the critical point wiki entirely missed. - It is the reason why the result obtained coresponde to thin "slices" transverse to the axis of the magnetic field. But first let me note that back in my day, it was NMR (Nuclear Magnetic Resonace) but that was when people were still either rational or ignorant about things "nuclear," and NMR was mainly a chemist's tool.
Wiki is correct about it being built on the fact the nuclear spin of hydrogen is 1/2 but they do not tell that it is because of the QM uncertainity principle that this spin doesn not exactly align with the magnetic field, no mater how strong it is. If you put a regular bar magnet in the unit and could keep if from flying out due to the small axial gradient it would be torqued into "perfect" alignment; however, the tiny magnet of the proton can not so align, because if it did you would precisely know or measure all three x,y,z components of it in violation of the uncertainity principle. {I.e. either it is (0,0,1/2) or (0,0,-1/2) if it were perfectly aligned}* Fact MRI works is just one more, (of thousands) of pieces of supporting evidence for QM and there is zero experimental evidence against quantum mechanics. A very practical one, but I digress.
Now, as it is NOT perfectly aligned, the torque I spoke of does exist, but like a gyroscope on the table with the torque of gravity acting on it, the resulting motion is a "precession" with a definite frequency, WHICH DEPENDS UPON THE STRENGTH OF MAGNETIC FIELD AT THE LOCATION OF THE PROTON. - that is the very critical point wiki missed. The magent field is extremely uniform across each plane perpendicular to the axis of the magnet but slightly different as you go along the axis of the magnet - why the mother cost so much! It is not very expensive to make a 1.5T field (or several times stronger one) if you do not care about the spatial variations or temporal duration. I have made stronger** ones with small, strong, single copper turn shorting out a fast (low-inductance) high-voltage capacitor with about hunderd dollars expended, mainly the capacitor but again, I digress.
When an RF field is briefly applied, say with frequency "f," ONLY in one of the transverse planes, say "F" is there exact resonace with the precession frequency of the proton. Recall there is a slight axial difference in the magnetic field strength and the precession frequency is lineraly proportional to the field strength.
In all other transverse axial planes, the RF does not reaonate or interact with much net effect on the precession, but in F while the RF is f, it causes a big resonacne effect - organizes them (I am not exactly sure how -must be their mutual interactions but in some sense they all in F get "wipping around together", which they would not normally do. So now after a very brief time if you turn off the RF they will "relax" back to their normal lack of sychronized precessions and in doing so make their own pulse of RF which you measure and record. (Sort of a "dying echo" of the RF pulse you applied.) I am not completely clear on how in practice this pulse is converted into a picture of the proton (read that as hydrongen) density as what I have so far described would just tell the total amount in the plane F. Perhaps there is also a small gradient in the transvers plane so the pulse really comes from a line, in the plane F, not the entire plane F. If this is the case and you slightly change the orientation of the line, but still keep it in plane F and collect some more data with another pulse, etc for many different lines in Plane F it is possible to process the data from all the "lines" in plane F to get a 2D picture or "slice" thru the body and know the spatially resolved density of hydrogen in plane F. (One such "mathematical invesion" is called the "Abel inversion" after a Sweedish mathematican who did work on the Nothern lights, also I think, and had a similar "inversion problem" which he solved.) but I do not know if that is how it is done. I.e. I never worked in this field. - I only understand the basic physics of it.)
Anyway after you have the data you need to the accuracy you can get, you move on to RF of frequency "g" and get data on the hydrogen density, spatially resolved in plane "G." etc. I did digress at end of the just prior paragraph also about Abel and myself, but I saved the last permited "smilie" for now.
If anyone who actually knows more of the details instead of only the principles please correct me where I error, if I did, or expand my discussion. - Thanks.
Few will read to here. I know that, but I love to teach. - Not essential that anyone learn, but it is nice if they do.
-----------------
*Telling which of those two it is easy as the precession frequencies are different. (Start with a much weaker field that does not align it, measure the precession frequency, and then increase the field strength until you have violated the uncertainity principle, by almost exactly aligning the proton's spin, if that were possible.)
**So strong that their dB/dt will ionize low pressure air in glass tube - sort of a "no electrode" very-bright flash bulb.
PS, I probably should, but never do, correct wiki - they make too many errors for that. Feel free to do so, if you like.