Sounds like proctalgia fugax, which is a benign condition.
But it could be very painful. It's thought to be due to spasms of pelvic muscles, surrounding your rectum. It's usually very short- lasting and self- resolving. Heating pad
or massaging the area could be helpful. But then again it could be due to other conditions. If it is bothering you a lot, it would be a good idea to see a doctor.