Sometimes dogs have issues with the anal glands. The anal glands are located just inside of the rectum. There are two drainage ducts that allow the anal gland material to drain out when the dog has a bowel movement. Sometimes those drainage ducts become blocked and the glands become too full. The glands can also become infected. It is pretty easy to treat. First, I would have a veterinary nurse, or the vet, check the glands and drain them. This is done by inserting a finger into the rectum and manually draining the material out. If it looks like "pus," he will be sent home with antibiotics.
He could also have injured his lower back or hips. I am thinking you can give him an aspirin for pain this evening. The dose is 5 mg of aspirin, per pound of dog, every 12 hours. For example a 10 pound dog would get 50 mg of aspirin. Give it with food to help prevent gastrointestinal upset.
If he starts to have abdominal signs, such as lack of appetite, vomiting, or diarrhea then it is a gastrointestinal tract issue. To help settle his stomach, you can give him a human stomach acid reducer. Pepcid, or zantac, are good ones. They sell them at the grocery store. 1/4 tablet, per 10 pound of weight, every 8 hours as needed.
Also monitor his bowel movements. He may be constipated and that can cause hind end pain as well.
I hope this helps.
Let me know if you have more concerns.