The working principle of a memristor is based on the movement of ions or dopants within a thin film of material, typically a metal oxide. When a voltage is applied, these ions shift, causing a change in the resistance of the device. This change is retained even after the power is turned off, enabling the memristor to "remember" its past states, thereby acting as a non-volatile memory element.