Atopic dermatitis is associated with substantial morbidity in childhood. Further understanding of the underlying factors contributing to its onset is needed. To assess the association of exposure to antibiotics in the prenatal period and early childhood with risk of atopic dermatitis in a nationwide population in Sweden. This Swedish nationwide, register-based, prospective cohort study used data on mother-child pairs from the Swedish Medical Birth Register linked to other national registers for information on health, socioeconomic, and demographic data. Participants were followed up until an atopic dermatitis outcome, emigration, death, or the end of the study on December 31, 2015. Data for all singleton children and discordant siblings born between March 1, 2006, and December 31, 2010, were included. Data were analyzed from June 1, 2020, to October 31, 2020. Maternal exposure to systemic antibiotics during pregnancy as well as the child's exposure to systemic antibiotics during the first year of life, as defined by a dispensed prescription in the Swedish Prescribed Drug Register. Time-to-event analyses were used to estimate the risk of outcome using attained age as a time scale. Atopic dermatitis was defined based on diagnoses in the National Patient Register and medication listed in the Swedish Prescribed Drug Register. Sibling-control analysis was performed to account for shared familial factors. Among the 722 767 singleton children, the mean (SD) age was 5.8 (2.4) years and 351 589 (48.6%) were female. During the follow-up period, 153 407 children (21.2%) were exposed to antibiotics in utero and 172 405 children (23.8%) were exposed during the first year of life. The risk of atopic dermatitis among children exposed to prenatal antibiotics was greater than that among children who were not exposed (adjusted hazard ratio [aHR], 1.10; 95% CI, 1.09-1.12). In the sibling-control analysis, no association was observed (aHR, 0.96; 95% CI; 0.92-1.00). Exposure to antibiotics during the first year of life was associated with a greater risk of atopic dermatitis (aHR, 1.52; 95% CI, 1.50-1.55), with attenuated associations in the sibling-control analysis (aHR, 1.24; 95% CI, 1.20-1.29). In this cohort study, exposure to antibiotics in early life was associated with an increased risk of atopic dermatitis in the general Swedish population, but this risk was partially confounded by familial factors. Research on the ways in which antibiotic use and other shared familial factors affect other atopic diseases may be warranted.