Objectives This study aimed to assess the association between postpartum hospital length-of-stay and the composition of gut microbiota at 3 and 12 months of age in different birth modes. Design Prospective cohort of Canadian infants from the Canadian Healthy Infant Longitudinal Development (CHILD) Study born between 2008 and 2012. Setting General community. Sample 1313 infants from three study sites (Edmonton, Vancouver, and Winnipeg) of the CHILD cohort Methods Duration of hospital stay was documented in hospital records. Infants’ gut microbiota was characterized by Illumina 16S rRNA sequencing of fecal samples at 3 and 12 months. Main outcome measures Infant gut microbiota profiles. Results: In the absence of maternal intrapartum antibiotic (IAP) exposure, vaginally delivered infants (VD) with a longer hospital length-of-stay (LOS) had a higher abundance of bacteria in their gut known to cause hospital-acquired Infections (HAI), including Enterococcus at 3 months and 12 months and Citrobacter at 3 months of age. Moreover, HAI-causing bacteria Enterobacteriaceae were more abundant in later infancy in postnatal prolonged hospital stayed IAP-exposed caesarean section (CS) infants. Enterococcus or Citrobacter abundance at 3 months significantly mediated the association of LOS with low relative abundance of Bacteroidaceae and a high relative abundance of Enterococcaeae/Bacteriodaceae or Enterobacteriaceae/Bacteroidaceae ratio at 12 months of age in VD infants without IAP exposure. Conclusions LOS after birth is associated with infant gut dysbiosis. Further research is needed to explore the health outcomes of these associations.