Other indicators of sex are subject to similar variations. The so-called biological line between male and female is frankly quite fuzzy. So much for sex. But sex is not gender. Sex is biological.
Gender is social, cultural, psychological and historical.
It is used to describe people and their roles in society, the jobs they do and the way they dress, how they are meant to behave. A person's gender is usually assigned at birth, with a cursory look at the genitals. The 'boy' or 'girl' which is documented on the birth certificate affects almost everything else that happens to that child socially for the rest of his or her life. The third gender Responses to ambiguous genitals vary from culture to culture. But in some societies that do not have access to surgery or whose world view is not mediated by biological 'facts' of science, there is more space for those who don't fit the norm.