Check your kitten and observe its legs and back end minutely. It might have some wound or something like that. If you do not find anything then you don’t have another choice but to take it to vet. He will examine it thoroughly and diagnose exact problem. I can not prescribe any medicine at the moment without knowing the exact cause which seems not possible by considering only your described symptoms. So take it to vet.
One time when I came home my cat was doing something similar with the addition of uncontrolled rapid eye movement. I took him to the vet who told me that the cat had probably gotten into something toxic. The episode passed with no recurring problems. You might also consider that the cat could have some type of intestinal problem, i.e. Kidney stones, urinary infection, etc. I would recommend seeing a vet if the problem persists longer than 3 or 4 days.