​​How does Active Noise Cancelling Headphones work?

Microphone - A microphone placed inside the ear cup "listens" to external sounds that cannot be blocked passively.
Noise-canceling circuitry - Electronics, also placed in the ear cup, sense the input from the microphone and generate a "fingerprint" of the noise, noting the frequency and amplitude of the incoming wave. Then they create a new wave that is 180 degrees out of phase with the waves associated with the noise.
Speaker - The "anti-sound" created by the noise-canceling circuitry is fed into the headphones' speakers along with the normal audio; the anti-sound erases the noise by destructive interference, but does not affect the desired sound waves in the normal audio.
Battery - The term "active" refers to the fact that energy must be added to the system to produce the noise-canceling effect. The source of that energy is a rechargeable battery.