NMR has been in use since the 1940's, in the form of spectroscopes. A small sample is placed in the strong electromagnet field and then bombarded with radio frequency magnetic waves. The electrons are excited into more energetic states (AKA "orbits" incorrectly) and when they decay back into the original state they give off a very specific wavelength. The various wavelengths tell you exactly what elements are present in the sample, and their amplitudes tell you the concentrations. I actually used one in the 80's to analyze lake bed sediments for a limnology course in college.

MRI put a person in a much bigger electromagnetic field and does the same thing. The difference is that NMR spectroscopes use a detector with non-directionality, while MRIs assemble an image from lots of those electron decay events. This was not practical until we had the processing power to turn millions of 2D images into 3D images, because the detectors can't tell how deep the decay event was, just left/right and up/down. They correlate detections from multiple detectors to come up with a depth, which is the big difference between a 3D image and a flat image like X-ray or ultrasound.

This image processing is the huge difference between NMR and modern MRI technology. Interesting bit of trivia: NMR detects all elements. MRI usually just detects Hydrogen, since we are so very much water.