MRI works by utilizing strong magnetic fields and radio waves to create detailed images of the body's internal structures.