The Wikipedia article on Image Stabilization has quite a bit of information. Below are some of the relevant sections.
For in lens stabilization:
In Nikon and Canon's implementation, it works by using a floating lens element that is moved orthogonally to the optical axis of the lens using electromagnets. Vibration is detected using two piezoelectric angular velocity sensors (often called gyroscopic sensors), one to detect horizontal movement and the other to detect vertical movement. As a result, this kind of image stabilizer only corrects for pitch and yaw axis rotations, and cannot correct for rotation around the optical axis. Some lenses have a secondary mode that counteracts vertical camera shake only. This mode is useful when using a panning technique, and switching into this mode depends on the lens; sometimes it is done by using a switch on the lens, or it can be automatic.
Some of Nikon's more recent VR-enabled
lenses offer an 'Active Mode' that is
intended to be used when shooting from
a moving vehicle, such as a car or
boat, and should correct for larger
shakes than the 'Normal Mode'.
However, Active Mode, when used under
normal shooting conditions, can result
in poorer results than the 'Normal
Mode'.
For in camera stabilization:
The sensor capturing the image can be moved in such a way as to counteract the motion of the camera, a technology often referred to as mechanical image stabilization. When the camera rotates, causing angular error, gyroscopes encode information to the actuator that moves the sensor. The sensor is moved to maintain the projection of the image onto the image plane, which is a function of the focal length of the lens being used; modern cameras can acquire focal length information from the lens. Konica Minolta used a technique called "anti-shake" now marketed as SteadyShot in the Sony α line and "shake reduction - SR" in the K10D, K20D, K-7, K100D, K200D, K-m (K-2000) and K-x lines by Pentax, which relies on a very precise angular rate sensor to detect camera motion. Olympus introduced image stabilization with their E-510 D-SLR body, employing a system built around their Supersonic Wave Drive. Other manufacturers use DSPs to analyze the image on the fly and then move the sensor appropriately. Sensor shifting is also used in some cameras by Fujifilm, Pentax, Samsung, Casio Exilim and Ricoh Caplio.
And finally, for video, there is software based image stabilization that occurs during post processing.