A stochastic actor-based model was used to investigate the origins of sex segregation by examining how similarity in sex of peers and time spent in gender-typed activities affected affiliation network selection and how peers influenced children's (N = 292; Mage = 4.3 years) activity involvement. Gender had powerful effects on interactions through direct and indirect pathways. Children selected playmates of the same sex and with similar levels of gender-typed activities. Selection based on gender-typed activities partially mediated selection based on sex of peers. Children influenced one another's engagement in gender-typed activities. When mechanisms producing sex segregation were compared, the largest contributor was selection based on sex of peers; less was due to activity-based selection and peer influence. Implications for sex segregation and gender development are discussed.