I had that when I was a teenager. It was due to being a bit nervous, and clenching my teeth and grinding them at night.
One day I could not open my mouth. I kid you not. I could not open it higher than to get a pencil in. My mum made semolina for breakfast, I fed myself with a knife, as it was flat, I could not even get a spoon in.
I got exercises for my jaw, it took a few weeks, the pain was unbearable. I lost a lot of weight.