AC motors are powered by AC, or alternating current. Unlike direct current, or DC power, which always flows in the same direction, AC switches back and forth from negative to positive dozens and even hundreds of times a second. For example, the AC coming into households in most of the world is 60 hertz, which means it switches directions 60 times a second. Since the speed of AC motors is controlled by the frequency of their current, they generally need much higher frequencies. An AC inverter changes the frequency to control the speed of the motor.
AC to DC
Before the power supply can be turned into the correct frequency, it has to be turned into AC. Inverters do this with a circuit called a rectifier---the same type of circuit that supplies power to electrical adaptors. The main component in a rectifier is a diode, which works similar to a one-way valve. It allows current to flow in one direction while stopping it from flowing in the other. AC current flows into the rectifier. When it is positive, diodes attached to the positive wire let it through, while diodes attached to the negative wire stop it from flowing. When it is negative, the opposite thing happens and the current flows down the negative wire. All the rapid negative and positive pulses of AC are turned into one continuous stream of negative voltage down one wire and another stream of positive voltage down another.
Generating the Wave
A digital circuit controlled by an operator or computer generates whatever frequency the motor needs. This circuit has switches that can be flipped on and off many thousands of times a second. Normal AC electricity flows in a smooth sine wave from positive to negative. The switches in the frequency generator, however, don't make a smooth wave. Instead, they make a stair-step wave---a wave with many small, discrete steps that add up to an approximation to a sine wave. This is similar to how digital music works.
Powering the Motor
AC motors have a metal rotor in the middle surrounded by several coils. When electricity runs into the coils, it produces a magnetic field. This induces a magnetic field in the opposite direct inside the rotor. When the electric current reverses in the coil, the direction of the magnetic field also changes, changing the field in the rotor. Because the magnetic field changes so fast, however, there is a lag. The field in the rotor doesn't change fast enough to stay in sync with the coils. Because it is out of sync, the rotor is repelled by the coils and starts turning to sync up to the coils. The speed at which it turns is controlled by the speed of the current in the coils---the faster they change direction, the faster the rotor has to turn to keep up with them. The inverter controls the speed at which the current changes direction and, hence, the speed of the rotor.