"Sex" reflects the biological equipment an individual possesses. People are classed accordingly, predominantly "male" or "female", but also some additional categories for the small percentage of the population who do not cleanly fall within those two. (Sex is sometimes assigned according to chromosome configuration, but this doesn't always neatly line up with anatomical classifications.)
"Gender" in contrast is socially constructed and/or psychological, and has to do with the roles an individual plays (or aspires to play) within society -- including but not limited to "sexual orientation". It is also conditioned to a significant extent by social expectations, which can vary widely from one culture to another or even within a single culture based on factors such as class.
The two concepts align for many individuals within a society, but clearly there is room for significant misalignments along several dimensions.
I, for example, am a heterosexual male, which covers the primary alignments. But, because of type of work, hair length, Volvo-driving, and some other aspects of my lifestyle I no longer align very well with the concept of "being a man" that I grew up with in the rural South.
Keep Up with TechRepublic