Poor sleep quality and psychological distress in pregnancy are important health concerns. Serotonin and melatonin levels may underlie variation in these adverse outcomes. In this study, we examined dietary nutrients involved in serotonin and melatonin synthesis in relation to maternal sleep quality and affective symptoms during pregnancy. Pregnant women at no greater than normal medical risk at enrollment completed 24‐hour dietary recalls in mid‐late pregnancy. Usual intakes of vitamin B6, vitamin D, eicosapentaenoic acid (EPA) + docosahexaenoic acid (DHA), and tryptophan were estimated from dietary intake of foods and supplements using the National Cancer Institute (NCI) method. Sleep quality, depression, and anxiety were measured using validated questionnaires. Associations between nutrient intakes, sleep quality, and affective symptoms were estimated using generalized estimating equation models adjusting for potential confounding factors. In minimally adjusted models, EPA + DHA and tryptophan intakes were associated with a lower score indicating better sleep quality (b: −1.07, 95% CI: −2.09, −0.05) and (b: −12.40, 95% CI: −24.60, −0.21), respectively. EPA + DHA and tryptophan intakes were also associated with a lower odds of shorter sleep duration and sleep disturbances. In addition, tryptophan was associated with a lower odds of higher sleep latency. However, associations were attenuated and nonsignificant after adjustment for demographic and lifestyle factors. In conclusion, intakes of EPA + DHA and tryptophan were associated with improved sleep quality, but these associations were confounded by maternal demographic and lifestyle characteristics. This study highlights the need to consider dietary intake and pregnancy health in the context of demographic characteristics and lifestyle behaviors.