M.H.
In my son's case, same problem at the same age.. I assumed night terrors, mayeb from being woken up by a noise, a dream, an erections or maybe the his teeth/molars were a discomfort. So many things to get a kid rattled in the middle of hte night.
I can only say that I am sure he was not thinking clearly, and could not communicate much of anything. Therefore, I stuck with one plan....
I would hold/hug him firmly and sing "you are my sunshine", and lots of whispering "ssshhhhhh, you're ok, I'm right here"
He really tried to squirm out every time, but I was on the bed, so I would just keep him contained and safe from hurting himself....the fetal position in my arms seemed to be most successful. He would scream and flaling his arms, trying to get me away.. So bizarre.. and it's all over in 5 minutes.
I never really knew it meant anything until 6 months later... he was upset about something and asked me to sing him the "deer" song.
what? I tried every song I knew because I had no idea what one he wanted..... it turns out he was asking for
that "you are my sunshine" song.. there is a line in there "if you only knew DEAR, how much I love you......"
So even though they are "out of it" during the episode, they can hear you.
I vote to add some soft words or song to your effort of holding him.