I've been playing guitar for a little while now and I'm noticing some great improvement in my technique. Lately, however, I've notice that when I play for long periods of time, my arm muscles and thumb joint muscles (for anchoring on the neck) really begin to hurt and it forces me to put the guitar down.

Now I've been routinely stretching and trying to play more to build up resistance in said muscles, but I'm looking for ways/excercises that I can do to build up my endurance, specifically the thumb muscles. Anyone know of some good ways to work these muscles and extend the amount of time I can spend playing?
Relax your grip on the neck. Part of your improving technique is to not only play the notes and chords you want to play but then to determine the lightest pressure needed on the frets to do it.

So once you work out the fretting to whatever youre playing, next step is to practice the lightest touch needed to do it and incorporate economy of finger movement. This will relax your grip and improve the efficiency in your fingerwork. Both of which help with the thumb cramp and will also help with improving speed.

While you do that also use a grip ball to squeeze periodically through your practice sessions.
^ Agreed, there's no reason you should be having pain, and especially not cramping, when playing the instrument, regardless of your level of experience. If you're cramping at the thumb, you need to relax your grip! Play your instrument with as little energy expendature as possible...it takes a very tiny amound of force to move the string far enough to contact the fret and ring clearly. Continue with a vice grip like that and you'll end up with tendonitis and surgery like I did.