Essentially, the speakers pick up the sound they want to cancel with a microphone, then put out a sound wave that's the opposite of that noise to cancel it out.
Well they basically use noise to contract the ambient noise around you. A frequencies is played through the speaker essentially canceling out the unwanted sound waves.
They work using appropriate noise filters in order to divide the usefull electronic signal from the noise disturbance. A filter is an electric device designed to do as I described.
One possibility is that the speakers record the noise of of the environment and create an anti-noise, which overlaps the noise and therefore remove it to the user of the speakers.