Early life gut microbiota-influencing factors may play an important role in programming individuals long-term health and substantial efforts have been devoted into studying the development of the gut microbiota in relation to early life events. This study aimed to examine in a single study, the persistence of associations between 20 factors occurring in the early life and the gut microbiota at 3.5 years of 798 children from two French nationwide birth cohorts, EPIPAGE 2 (very preterm children) and ELFE (late preterm and full-term children). Gut microbiota profiling was assessed using 16S rRNA gene sequencing-based method. Upon thorough adjustment of confounding factors, we demonstrated that gestational age was one of the factors most associated with gut microbiota differences with a noticeable imprint of prematurity at 3.5 years of age. Children born by cesarean section harbored lower richness and diversity and a different overall gut microbiota composition independently of preterm status. Children who had ever received human milk were associated with a Prevotella-driven enterotype (P_type) compared to those who had never received human milk. Living with a sibling was associated with higher diversity. Children with siblings and those attending daycare centers were associated with a P_type enterotype. Maternal factors including the country of birth and preconception maternal body mass index were associated with some microbiota characteristics: children born to overweight or obese mothers showed increased gut microbiota richness. This study reveals that multiple exposures operating from early life imprint the gut microbiota at 3.5 years that is a pivotal age when the gut microbiota acquires many of its adult characteristics.