The relationships between long-term antibiotic use during early life and mental traits remain elusive now. A total of 158,444 subjects from UK Biobank were used in this study. Linear regression analyses were first conducted to assess the correlations between long-term antibiotic use during early life and mental traits. Gene-environment-wide interaction study (GEWIS) was then performed by PLINK2.0 to detect the interaction effects between long-term antibiotic use during early life and genes on the risks of mental traits. Finally, DAVID tool was used to conduct gene ontology (GO) analysis of the identified genes interacting with longterm antibiotic use during early life. We found negative associations of long-term antibiotic use during early life with remembrance (p value=1.74 × 10 −6 , b = −0.10) and intelligence (p value=2.64 × 10 −26 , b = −0.13), and positive associations of long-term antibiotic use during early life with anxiety (p value = 2.75 × 10 −47 , b = 0.12) and depression (p value=2.01 × 10 −195 , b = 0.25). GEWIS identified multiple significant genes-long-term antibiotic use during early life interaction effects, such as ANK3 (rs773585997, p value = 1.78 × 10 −8 ) for anxiety and STRN (rs140049205, p value = 1.88 × 10 −8 ) for depression. GO enrichment analysis detected six GO terms enriched in the identified genes interacting with long-term antibiotic use during early life for anxiety, such as GO:0030425~dendrite (p value = 3.41 × 10 −2 ) and GO:0005886~plasma membrane (p value = 3.64 × 10 −3 ). Our study results suggest the impact of long-term antibiotic use during early life on the development of mental traits.