I've recently started playing guitar at open mic nights with a friend, I'm predominantly a bassist so my guitar technique probably isn't perfect. During one particular song though (No one knows - QOTSA) I use barre chords a lot and at the end of the song there's an immense amount of pain in my fretting hand, mostly at the knuckles and partially in my fingers.

Is this something that goes away with time or am I gimping myself with stupid fretting technique?
I've been playing guitar for about 4 or 5 years, and it took me about a year and a half to start getting barre chords to sound clear. I don't know if its just me and you, or if our technique is just bad, but my barre chord pain never goes away. I can play through maybe one or two songs with barre chords and my hand feels a cramped mess.

I don't think its my technique, my hand seems to be postured the same as anyone else's, but then again that just might be a problem everyone has. I'm not so sure myself either.
Treble>Epiphone Prophecy EX - MXR micro Amp - MXR Blue Box - MXR Fullbore - MXR Noise Clamp - Vox AD30VT
Bass>Ibanez BTB505 - MXR Blowtorch - MXR D.I. - Peavey MaxBass 700 - Peavey TVX410
I still have the same problem while play for extended periods of time/playing live. One thing I've begun doing is: say if I'm playing a G major barre chord, I'll only use my index finger to hold down the low E string, since my other fingers are hitting the other notes. Before, I would lay my index finger down the entire third fret, hitting all the strings, and then use my other fingers onto of that. It made my wrist/hand ache, and the new way is a little bit less strain, which translates to more accurate, longer playing times. Give it a try.
Fender American Deluxe V-Neck Strat
Laguna LG300CE Acoustic Electric
I ALWAYS get a major cramp in the fleshy part in between my index finger and my thumb. It only happens with barre chords after playing them for several minutes straight. I don't know what is causing it and if it's normal or not, but it definitely starts to hurt. I know how you feel.
PRS SE Custom 22
Peavey Vypyr 30

"When you look into the eyes of a man grown old,
wonder about the secrets gone untold.

When you look into the eyes of a young child,
marvel at the innocence running wild."
At an open mic night, I assume you're playing acoustic. I've been playing for 6 years, and while playing acoustic barre chords still cause pain. Not usually in my fingers, but in my wrist. I don't know if this is just normal, or if it's my technique, but barre chords have never caused me any discomfort on electric.
For the past few years I've had the same problem with cramp but when I was 17, and practiced guitar nearly every day, I never had any problems. So I believe it's just a lack of conditioning. If you want to play barre chords for 30 minutes, practice playing them for an hour. You'll soon get your hands 'in shape'. It is literally a painful process but you get there in the end. Also, stop if the cramp becomes properly painful, you can do real damage. I'd only say play through the pain if you're playing a gig.
Try altering your barre chord technique a little bit. Of course you want to apply pressure with your fingers, as your naturally do with guitar. However, try to apply the pressure from your triceps. If this makes any sense, try to basically "pull" your hand closer to the neck by tightening up your tri's a little bit. This will help you apply more pressure in an easier way to get all the strings sounding clearly. Try it out, let me know how it goes or if you have any questions
You are playing an acoustic, what gauge are your strings? If you are using anything heavy, barre-chords become hard or impossible. If you are using light gauges, try adjusting a your posture/technique.

Personally I never have had this except on heavy gauge acoustics (15, 14 is meh)
Gibson Les Paul Custom (Aged White)
Custom Kramer Baretta
Custom Fender Strat
Epiphone Black Beauty
Epiphone AJ
Marshall JCM900 4201
Blackheart Little Giant
MXR Dist. +
MXR Six Band EQ
MXR Phase 90