Human sex ratios at birth (SRBs) shape population composition and are closely linked to maternal health and gender discrimination. In the context of environmental change, SRBs may theoretically be skewed by physiological or behavioral responses to exposure to extreme heat. However, evidence for this is limited. In this study, we estimate the effect of prenatal exposure to temperature on birth sex by linking survey data on 5 million live births in 33 sub-Saharan African countries and India with high-resolution temperature data. To distinguish between spontaneous and induced abortions, we exploit sociodemographic differentials, exposure timing, and regional differences in son preference. We find that days with a maximum temperature above 20 °C are negatively associated with male births in both regions. In sub-Saharan Africa, we observe fewer male births after high first-trimester temperature exposure, consistent with increased spontaneous abortions from maternal heat stress. This is particularly true for births by mothers in rural areas, with little formal education, and for higher birth orders. By contrast, in India, we find that second-trimester temperature exposure is associated with fewer male births, consistent with reductions in induced sex-selective abortions. As expected, these reductions are concentrated in high birth orders and older mothers. We also find large reductions in male births by sonless mothers in northern Indian states, where son preference is greater. These findings demonstrate that heat exposure harms maternal health, increases prenatal mortality, and influences family planning behavior, leading to a complex effect on SRBs.