Mother–child separation harms children's development. This concern is particularly relevant in rapidly urbanizing societies with massive migration. However, factors that increase the probability of children becoming separated from their migrating parents are not well understood. In this study, we find that during early childhood, specifically at the age of 2 years, girls are less likely to become separated from their parents than boys are. This is due to son preference, which leads parents to attempt to have another child after a firstborn daughter, mostly when the daughter is 2 years old. Furthermore, migrant women often stay in their hometowns during pregnancy, which prevents mother–daughter separation. Our placebo tests indicate that this gender gap at the age of 2 years does not exist in provinces with birth interval restrictions or strict one-child policies. The gap is wider in regions with stronger son preference or higher historical population outflow rates.