It doesn't have to be too strenuous of an effort. Sometime just a small movement in the right (or wrong) direction can cause a great spasm and be very painful. The fact that changing your position changes the pain is relevant I think.
Go easy for a couple of days, and if it still doesn't go, consult your physician.