A control moment gyroscope (CMG) is a means of generating torque around a particular axis in order to produce controlled rotation. Generally, they are used in spacecraft to provide attitude control via electrical power instead of using consumables in a reaction control system. There are other advantages - they don't contaminate the surrounding space with ejecta, for one. The power to operate them can come from renewable sources such as solar panels or even a RTG. CMGs operate similarly to reaction control wheels in this respect.

CMGs consist of (at base) one more more rotors, mounted on gimbals. The CMG can rotate the spinning gimbal around an axis at right angles to its axis of spin. By the math and physics of gyroscopic motion, that will produce a torque around another axis due to the conservation of momentum. Thus, a vehicle which has CMGs rigidly mounted to itself can control its attitude by tilting the CMG rotors. The actual power needed to produce a given torque is actually much lower than that required to do so via an equivalent reaction control wheel, because the momentum is already contained in the spinning gyroscope. Only enough power to generate the desired rotational torque is necessary at the time of rotation. Generally, studies have shown that while the power required to achieve a specific torque using control wheels scales as d5, where d is a 'characteristic dimension of the spacecraft' (such as length or width - TC). However, to achieve a given torque, a CMG generally requires on order of d2 - which is much, much more reasonable. Power generation via solar collector scales as d2 as well, meaning that above a certain size, a spacecraft will be essentially forced to use CMGs over reaction wheels.

Why would we ever use control wheels, then? Well, there are a few reasons. First, the CMG is a more complex device both in terms of operating parts and in terms of control law. The ratio of the mass of the rotor to the mass of the spacecraft will make a difference in the total magnitude of torque it can generate as well - unlike the control wheel, spinning the control mechanism faster won't generate more torque. Making a CMG that doesn't have a 'gimbal stop' - I.e. that can freely rotate in one more more directions to avoid a limited range of motion - is more difficult. Finally, in order to produce the appropriate torque for a given maneuver, you need to know the current position of the CMG rotors in order to perform the calculations, making maneuver planning more expensive computationally. As a result, CMGs tend to be built into larger spacecraft, whether manned or unmanned, as below a certain size (d) reaction control wheels are good enough.

Like RCWs, it's possible to end up in a situation where your CMGs can't help you anymore. RCWs call this 'saturation.' CMGs have a saturation point as well! If all CMGs on a spacecraft end up with their rotors aligned, it will be impossible to produce a torque around one axis. In that case, a momentum dump will be required, just as it would be with control wheels, using consumable RCS fuel or perhaps other means - if the spacecraft is within a large body's practical magnetic field, an electrodynamic tether might be used. It is also possible for the CMG set to achieve 'singularity', I.e. pass through a state where the axes are aligned in such a way as to suddenly prevent torque generation in the necessary axis. A great deal of math and study has been done to minimize the conditions under which this can occur, and are beyond my ken.