ESR works by applying a magnetic field to a sample and then using microwave radiation to induce transitions between the magnetic energy levels of unpaired electrons. The absorption of this radiation is detected and analyzed to provide information about the electronic and magnetic properties of the sample.