Dropped by to say gender is your 'mental sex.' Sex is your 'physical sex.' Then again, on the Internet, I suppose the first matters more so than the latter. (Someone has probably already mentioned this, I presume.)
What Cspr means is that gender is in the mind, where as sex is what is biological. Sex, male and female, is what your body is. Gender, woman or man (or other, neither, both, etc), is how you perceive yourself. You may have a certain reproductive organ, but that doesn't mean that you associate with it. You may have female features, for instance, but feel as though you are a man, which you may demonstrate through the clothes you wear, activities you partake in, and possibly through your choice in partners.
For according to the trollish philosopher Plateau, "if you wants to understan' an enemy, you gotta walk a mile in his shoes. Den, if he's still your enemy, at least you're a mile away and he's got no shoes." — A Blink of the Screen by Terry Pratchett