Muscles or joints. In the absence of a fever or other signs of infection, a stiff neck usually is the result of muscle hyperactivity or possibly arthritis. Depending on your age, as always, you need a diagnosis. Heat, muscle relaxants, anti-inflammatory meds may help. But as I so often emphasize in these short answers, seek a diagnosis. Treatment will logically follow. Seeing a physiatrist comes first.
Heat, exercise. If you have a fever over 102º and neck is very stiff, see doc at once; you may have meningitis. If temp is normal, apply moist heat to neck & shoulders; gently exercise the neck in all directions; massage may help relax muscles; osteopathic manipulation can relax muscles & correct spinal "lesions". Use nsaids (advil/motrin/etc if stomach tolerates them & you're not on a blood thinner) for pain.