It works using the wheel speed (abs) sensors. If a tyre deflates, its overall diameter reduces, therefore increasing the wheel's rotational speed and triggering the sensor.
On occasion, the sytem can be fooled if you go over a bump, a wheel leaves the ground, or you get a bit of wheelspin, but it happens too quickly for the ESP to step in and tell the TPS that it has the situation in hand.