Better risk prediction and new molecular targets are key priorities in type 2 diabetes (T2D) research. Little is known about the role of the urine metabolome in predicting the risk of T2D. We aimed to use non-targeted urine metabolomics to discover biomarkers and improve risk prediction for T2D. Urine samples from two community cohorts of 1,424 adults were analyzed by ultra-performance liquid chromatography/mass spectrometry (UPLC-MS). In a discovery/replication design, three out of 62 annotated metabolites were associated with prevalent T2D, notably lower urine levels of 3-hydroxyundecanoyl-carnitine. In participants without diabetes at baseline, LASSO regression in the training set selected six metabolites that improved prediction of T2D beyond established risk factors risk over up to 12 years' follow-up in the test sample, from C-statistic 0.866 to 0.892. Our results in one of the largest non-targeted urinary metabolomics study to date demonstrate the role of the urine metabolome in identifying at-risk persons for T2D and suggest urine 3-hydroxyundecanoyl-carnitine as a biomarker candidate.