I had the same problem today with my Moto X 2nd gen. Dropped the phone from chair: height = 20 cm.
I read here:
http://forums.androidcentral.com/google-nexus-4/264976-screen-won-t-rotate.html
slapping on the back of the phone( middle or a bit low in my case) fixed my problem. I just slapped 3 to 4 times moderately. and it works for me. (now I can sleep with peace...)
This is funny though: (read the comments as well before trying any thing)
https://www.reddit.com/r/Nexus6P/comments/3to0ds/broken_accelerometer_try_dropping_your_phone
'''Obviously, I take no responsibility for further damage resulting from following any actions as mentioned or linked. Try them at your own risk. '''