In males, the presence of the SRY gene on the Y chromosome triggers the differentiation of the gonadal ridge into testes. Histologically, this involves the formation of Sertoli cells and the initiation of Leydig cells to produce testosterone. In females, the absence of the SRY gene leads to the gonadal ridge forming ovaries, characterized by the development of follicular cells and the absence of significant testosterone production.