SummaryBackgroundGestational age (GA) and associated level of gastrointestinal tract maturation are major factors driving the initial gut microbiota composition in preterm infants. Besides, compared to term infants, premature infants often receive antibiotics to treat infections and probiotics to restore optimal gut microbiota. How GA, antibiotics, and probiotics modulate the microbiota’s core characteristics, gut resistome and mobilome, remains nascent.MethodsWe analysed metagenomic data from a longitudinal observational study in six Norwegian neonatal intensive care units to describe the bacterial microbiota of infants of varying GA and receiving different treatments. The cohort consisted of probiotic-supplemented and antibiotic-exposed extremely preterm infants (n= 29), antibiotic-exposed very preterm (n= 25), antibiotic-unexposed very preterm (n= 8), and antibiotic-unexposed full-term (n= 10) infants. The stool samples were collected on days of life 7, 28, 120, and 365, and DNA extraction was followed by shotgun metagenome sequencing and bioinformatical analysis.FindingsThe top predictors of microbiota maturation were hospitalisation length and GA. Probiotic administration rendered the gut microbiota and resistome of extremely preterm infants more alike to term infants on day 7 and ameliorated GA-driven loss of microbiota interconnectivity and stability. GA, hospitalisation, and both microbiota-modifying treatments (antibiotics and probiotics) contributed to an elevated carriage of mobile genetic elements in preterm infants compared to term controls. Finally,Escherichia coliwas associated with the highest number of antibiotic-resistance genes, followed byKlebsiella pneumoniaeandKlebsiella aerogenes.InterpretationProlonged hospitalisation, antibiotics, and probiotic intervention contribute to dynamic alterations in resistome and mobilome, gut microbiota characteristics relevant to infection risk.FundingOdd-Berg Group,Northern Norway Regional Health Authority.