Have you seen those Circus artists that make plates spin around a very thin stick?
The idea around this robot is something similar ( and completely different at the same time ). Using a Gyroscope ( you need to buy it, it doesn’t come with the standard Mindstorms kit, but it will on the upcoming EV3 ) it is able to balance itself over two wheels.
If you think this is impressive, just wait to see this.
This self-balancing robot that mimics a Segway is able to maintain balance using the Color Sensor ( or even with old Light sensor will do ). It uses to shade of light that it reads from the the Color Sensor to know if it is going forward and backward and then, using a PID Controller to move the motor so it corrects the error on the balancing. All of this done using NXT-G.
Really, go and visit http://www.nxtprograms.com/NXT2/segway/ and build it yourself!