More concretely, is the SRY gene located in chromosome Y. There are several sex chromosome aneuploidies: https://en.wikipedia.org/wiki/Category:Sex_chromosome_aneuploidies
Of course, then gene expresion leads to hormone release which determines gender. For example, estrogen leads to brain masculinization under fetal development.