Objective Testosterone is a critical determinant of health in both genders. However, the relationship between circulating levels of testosterone and mortality remains undetermined. Methods We examined the associations of serum total testosterone (TT) and free testosterone (FT) with all-cause and cause-specific mortality in 154 965 men and 93 314 postmenopausal women from UK Biobank. Cox regression models were used to calculate the hazard ratios (HR) and 95% CIs. Given multiple testing, P < 0.005 was considered statistically significant. Results Over a median follow-up of 8.9 (inter-quartile range: 8.3–9.5) years, we documented 5754 deaths in men, including 1243 (21.6%) from CVD and 2987 (51.9%) from cancer. In postmenopausal women, 2435 deaths occurred, including 346 (14.2%) from CVD and 1583 (65.0%) from cancer. TT and FT concentrations were inversely associated with all-cause mortality in men, with the multivariable HR of 0.82 (95% CI: 0.75–0.91) and 0.80 (95% CI: 0.73–0.87) for the highest (Q5) vs the lowest quintile (Q1), respectively. In postmenopausal women, TT concentrations showed a positive association with all-cause mortality (HR for Q5 vs Q1 = 1.20, 95% CI: 1.06–1.37). Furthermore, higher TT and FT concentrations were associated with a lower risk of cancer mortality in men (both P for trend = 0.001), whereas TT concentrations were suggestively associated with a higher risk of cancer mortality in postmenopausal women ( P for trend = 0.03). Conclusions Our findings suggest that high levels of circulating testosterone may be beneficial for all-cause and cancer mortality in men but detrimental in postmenopausal women.