Abstract Study question Is there an association between use of proton pump inhibitors (PPIs) and maternal infection during or after pregnancy and subsequent pregnancy complications? Summary answer Use of PPIs in the 3 months before pregnancy or during the first trimester was associated with an elevated risk of maternal infection. What is known already PPIs alter gastric acidity and the gut microbiome, which may increase infection risks in the general population, but their impact on pregnant women is unknown. Study design, size, duration We conducted a Nationwide population-based cohort study using data from Swedish healthcare registers. PPIs use was defined as ≥ 1 prescription fill of a PPI in the 90 days before the first day of the last menstrual period (LMP) to the end of the 1st trimester (LMP+97 days). Maternal infections were identified from the start of the 2nd trimester to 90 days postpartum and classified as mild, moderate/ severe infections, and infection-related pregnancy complications. Participants/materials, setting, methods All pregnancies resulting in live or stillbirths between 2006 to 2019 in Sweden, identified using the Medical Birth Register. Log-binomial regression was used to estimate associations (relative risk (RR) and 95% confidence intervals (CI)) between PPIs and maternal infection, adjusting for potential confounders including birth year, maternal age at delivery, early pregnancy BMI, comorbidities, smoking in early pregnancy, maternal country of birth, maternal education, and parity. Main results and the role of chance Among 1,510,560 pregnant women, 42,599 (2.8%) used PPIs, and use increased over the study period time from 1.5% in 2006 to 3.44% in 2019. Compared to pregnant women without PPI use, those with PPI use had higher rates and risks of any infection (49.7% vs 36.8%; adjusted RR 1.30, 95%CI 1.29-1.32), mild infection (20.9% vs 16.1%; adjusted RR 1.30, 95%CI 1.28-1.33), moderate to severe infection (23.4% vs 15%; adjusted RR 1.47, 95%CI 1.45-1.50), and infection-related pregnancy complications (11.2% vs 9.2; adjusted RR 1.12, 95%CI 1.09-1.15). Conclusion Our results show an association between PPI use and an elevated risk of infection in pregnant women. Next steps include the further investigation into the infection types. PPI therapy has benefits and drawbacks that should be carefully weighed, especially in patients who are prone to infections. While our study highlights potential concerns, it does not imply that all pregnant women are at increased risk. More research is needed to understand the underlying mechanisms and assess potential preventive measures. Prescribing PPIs during pregnancy should be determined on a case-by-case basis, considering the patient’s individual health state. We acknowledge the necessity for caution, particularly in vulnerable populations, and more research is needed to demonstrate clinical correlations. Limitations, reasons for caution Potential confounding by indication due to underlying morbidities cannot be fully accounted for. Further research is required to establish clinical connections. Wider implications of the findings Clinicians should carefully weigh the benefits of PPI therapy during pregnancy, particularly in patients prone to infections. Trial registration number not applicable