Maternal metal(loid)s exposure has been related to preterm birth (PTB), but the results are still inconclusive. Previous studies have mainly discussed the harmful metal(loid)s, neglecting beneficial ones. We examined the association of maternal metal(loid)s with PTB and gestational age (GA) in a birth cohort from the Tibetan Plateau. We measured 29 metal(loid)s in urine samples from 1081 pregnant women in the third trimester. Information regarding demographics, socioeconomic status, diet, medication, and lifestyle was collected through standardized interviews. The associations of single metal(loid)s with PTB or GA were evaluated using a generalized linear mixed-effects model or linear mixed-effects model. Elastic net and Bayesian kernel machine regressions were used to explore the joint associations. Magnesium (Mg), Copper (Cu), and Tin (Sn) were the main “harmful” metal(loid)s positively and negatively associated with PTB or GA, respectively. Mg was the dominant “harmful” metal(loid)s associated with PTB in a J-shape. A one-fold increase in Mg was associated with a 38% increased risk of PTB [OR (95% CI) = 1.38 (1.15, 1.65), PFDR<0.05] and 0.17 weeks shortening of GA [β (95% CI) = −0.25 (−0.35, −0.14), PFDR<0.05]. Cesium (Cs), rubidium (Rb), and Molybdenum (Mo) were the main “beneficial” metals. Cs dominated the “beneficial” associations and was negatively associated with PTB in a linear manner. A one-fold increase in Cs was associated with a 67% decreased risk of PTB [OR (95% CI) = 0.43 (0.27, 0.67), PFDR<0.05] and 0.24 weeks of prolonged GA [β (95% CI) = 0.35 (0.13, 0.56), PFDR<0.05]. Ethnicity and living altitude modified the association of Mg and Cu with PTB or GA. In conclusion, Maternal urinary metal(loid)s were bi-directionally associated with PTB in a population in the Tibetan Plateau. Mg and Cs were the dominant “harmful” and “beneficial” metal(loid)s, respectively.