The reasons are somewhat similar to why the Tinman stiffened up in The Wizard of Oz . He stopped moving. While you may not have gotten caught in the rain and rusted, you did stop moving for a considerable period of time. During those hours of sleep, the body's core temperature has fallen and viscosity of the joints has decreased. In the Tinman's case, after few squirts of oil he was back in business.
People are a little more complicated.
Gently rock your pelvis up and down. As you do this motion, you should feel your lower back change from arching to flattening. Start with a small motion and gradually increase the range. After you do this for a minute or so, roll on to your back. Once on your back, alternately pull one knee to the chest while straightening the other leg.