If it is due to a traumatic incident it is best to call for medical assistance as you need to ascertain if anything is broken.
This following advice is meant as a guide and you should seek advice for your particular problem.
Assuming it is due to an unguarded movement (by that we mean the muscles didn’t support your joint) the best thing to do is get a flexible ice pack over the painful joint. This must be wrapped in a thin cloth to protect the skin from a burn. The length of time depends on the depth of the joint.
As a general rule do 10 mins for neck, upper back and limbs and 20 mins for lower back. Try to apply 3-4x a day, mainly from mid morning onwards. You will probably feel best having a hot shower in the morning to loosen the overnight stiffness.
The next important thing to do is stay mobile on a regular basis if possible. This may be difficult to do initially. However as you move you will inhibit pain, so start gently and gain flexibility slowly. Do not test your movement in the direction of pain, as it will only aggravate your condition.
You would as a general rule benefit by going into the pain free direction. Please note with sciatica due to a disc prolapse you go into the direction that reduces leg pain even it the back aches a little. Please see the section on sciatica for further information.