Massive wheels are mounted in three orthogonal axes aboard the spacecraft. They provide a means to trade angular momentum back and forth between spacecraft and wheels. To rotate the vehicle in one direction, you spin up the proper wheel in the opposite direction. To rotate the vehicle back, you slow down the wheel. Excess momentum that builds up in the system due to external torques, caused for example by solar photon pressure or gravity gradient, must be occasionally removed from the system by applying torque to the spacecraft and allowing the wheels to acquire a desired speed under computer control.
Many spacecraft use a system of thrusters to apply the torque for desats.
The Hubble Space Telescope, though, has sensitive optics that could be contaminated by thruster exhaust, so it used magnetic torquers that interact with the Earth's magnetic field for its desat maneuvers. There are advantages and disadvantages to both spin stabilization and 3-axis stabilization. If thrusters are used, optical observations such as imaging must designed knowing that the spacecraft is always slowly rocking back and forth, and not always exactly predictably. Reaction wheels provide a much steadier spacecraft from which to make observations, but they add mass to the spacecraft, and require frequent momentum desaturation maneuvers. No matter what choices have been made, spin or 3-axis stabilization, thrusters or reaction wheels, the task of attitude and articulation control falls to an AACS computer running highly evolved, sophisticated software.