fMRI works by detecting the differences in the magnetic properties of oxygenated and deoxygenated blood. When a specific area of the brain is more active, it consumes more oxygen, and the local blood flow to that region increases. The fMRI scanner detects these changes, allowing researchers to map neural activity in real-time.