Exposure to maternal hyperglycemia in utero has been associated with adverse metabolic outcomes in offspring. However, few studies have investigated the relationship between maternal hyperglycemia and offspring cortisol levels. We assessed associations of gestational diabetes mellitus (GDM) with cortisol biomarkers in two longitudinal prebirth cohorts: Project Viva included 928 mother–child pairs and Gen3G included 313 mother–child pairs. In Project Viva, GDM was diagnosed in N = 48 (5.2%) women using a two-step procedure (50 g glucose challenge test, if abnormal followed by 100 g oral glucose tolerance test [OGTT]), and in N = 29 (9.3%) women participating in Gen3G using one-step 75 g OGTT. In Project Viva, we measured cord blood glucocorticoids and child hair cortisol levels during mid-childhood (mean (SD) age: 7.8 (0.8) years) and early adolescence (mean (SD) age: 13.2 (0.9) years). In Gen3G, we measured hair cortisol at 5.4 (0.3) years. We used multivariable linear regression to examine associations of GDM with offspring cortisol, adjusting for child age and sex, maternal prepregnancy body mass index, education, and socioeconomic status. We additionally adjusted for child race/ethnicity in the cord blood analyses. In both Project Viva and Gen3G, we observed null associations of GDM and maternal glucose markers in pregnancy with cortisol biomarkers in cord blood at birth (β = 16.6 nmol/L, 95% CI −60.7, 94.0 in Project Viva) and in hair samples during childhood (β = −0.56 pg/mg, 95% CI −1.16, 0.04 in Project Viva; β = 0.09 pg/mg, 95% CI −0.38, 0.57 in Gen3G). Our findings do not support the hypothesis that maternal hyperglycemia is related to hypothalamic–pituitary–adrenal axis activity.