I used to put up with stiff neck 3 to 4 times a year in the past.
A veteran like me will sense it coming. Usually I get early symptoms in the morning during or before my shower. What I used to do then, was to very gently work the muscles in the area. That never helped. The pain and the stiffness would aggravate through the day, and would stay for the better part of a week.
Instead, you should consciously and deliberately r-e-l-a-x those muscles at that very instant. Imagine draining energy off the area. Will it away. Close your eyes and start relaxing the entire body, too. Stay that way for 30 seconds to a minute.
You can supplement this ‘treatment’ by applying deep heat rub afterward, but usually that is not necessary.
How effective is it? Well, I have not suffered a minute of stiffness in the past two years!