The association of infections and antibiotic use in pregnancy and the risk of inflammatory bowel disease (IBD) development in the offspring have been scarcely investigated. We examined infection and antibiotic use in pregnancy and the risk of IBD in offspring. We followed participants from the All Babies in Southeast Sweden (ABIS) and the Norwegian mother father and child cohort (MoBa) from birth (1997-2009) until 2020-2021. IBD diagnosis was classified as ≥2 records in national registers. Information on infections (any, gastrointestinal, and respiratory), their timing (early or late in pregnancy), and antibiotic use in pregnancy were collected from questionnaires. Cox proportional-hazard regression and meta-analytic methods were used to estimate pooled adjusted hazard ratios (aHRs) for IBD and its subtypes, adjusted for parental IBD, maternal smoking, and education. Sensitivity analyses accounted for exposure to antibiotics and infections 0-12 months of age. We followed 117 493 children for 2 024 299 person-years (follow-up 22.3 years in ABIS and 16.4 years in MoBa), including 451 IBD cases. The aHRs for any infection and respiratory infections in pregnancy and offspring IBD were close to one (aHR = 0.99 [95% CI = 0.73-1.33] and aHR = 1.00 [95% CI = 0.81-1.23], respectively). However, any versus no infection in early pregnancy was associated with IBD development (aHR = 1.26 [95% CI = 1.02-1.55]), particularly Crohn's disease (CD; aHR = 1.40 [95% CI = 1.01-1.93]). Any versus no gastrointestinal infection in late pregnancy was associated with offspring CD (aHR = 1.95 [95% CI = 1.34-2.84]). Antibiotic use in pregnancy was not associated with IBD in the child (aHR = 1.15 [95% CI = 0.93-1.44]). In this binational birth cohort study, the risk of offspring IBD varied by infection type and timing but not with maternal antibiotic use in pregnancy.