Permanent magnets work based on the alignment of magnetic domains. At the atomic level, materials have regions called domains, where the magnetic moments of atoms are aligned. In a permanent magnet, these domains are aligned in the same direction, creating a macroscopic magnetic field.