Baretta Boy's on the right track.
What I was taught is: "Control the weapon FIRST." At that close range, the weapon belongs to whoever has control of it, not necessarily the one who brought it. If you can keep him from drawing it by grabbing his wrist, or whatever, so much the better. If it's out of the holster, it gets tougher. If it is out, first you should do is make sure it isn't pointed at you (duh). Either grab it, or "slap" it away from you (down and away seems to work best), and move away from it at the same time (you get clear faster if you move it and you). Meanwhile, while his gun is pointed in another direction, you may be able to draw yours (or whatever).
There are techniques for disarming someone with a pistol at close range, but all the ones I've seen that I thought might work share the "move the gun away from you and you away from the gun" idea in one form or another. You should be aware of them - I garauntee that any former resident of our penal system has seen a few of these techniques (guards have guns, prisoners don't). Remember, it may be you who is trying to hold on to your pistol!
BTW, I know someone who has taken a gun away from a BG in a similar situation. The technique he used was sort of a "fishtail" type thing. It's hard to describe, but if anyone's interested, I'll try.
Another comment - if you can punch or use a palm smash to their face, you might want to eye gouge them instead. I recommend a "four fingered" gouge - tuck your thumb beside your hand & spread all four fingers apart. Try to strike with the middle two, and aim for the bottom of the eye socket. If you aim low and they duck, you still might get them; if they raise up, the slope of their cheekbone will sort of guide your fingers in; of course, the advantage to using all four is you get a little margin for error left-to-right.
Sorry for the long post...