Abstract Background Numerous studies have investigated the association between serum testosterone levels, testosterone replacement therapy (TRT), and cardiovascular risk. However, research examining the relationship between testosterone levels and atrial fibrillation (AF) risk remains limited. We comprehensively analyzed the association between total testosterone (TT) levels, intermediary phenotypes such as left atrium (LA) size and function, and the risk of AF in middle-aged and older men. Methods We utilized data from the UK Biobank, a population-based prospective cohort, focusing on 179,988 White men who had complete serum TT level data and no AF history. Observational associations between TT levels and LA imaging traits, as well as AF risk, were estimated using multivariable regression and time-dependent Cox regression models, treating TT levels as a time-varying variable. Genetic associations were examined by Mendelian randomization (MR), using both UK Biobank and external large consortia genome-wide association study data. Results During the median follow-up of 11.8 years (IQR 10.9–12.5), we observed 13,847 incident AF cases (7.7%). Participants with normal TT levels (≥ 300 ng/dL) showed a 15% reduced risk of AF (HR of 0.85 [95% CI, 0.82–0.89]) compared to those with low TT (< 300 ng/dL). Interestingly, participants undergoing TRT experienced a 51% higher risk of AF (1.51 [1.09–2.07]). Furthermore, each 1-standard deviation increase in TT levels was associated with a reduced AF risk (OR of 0.91 [0.89–0.93]) and an improved LA emptying fraction (1.29 [1.06–1.58]). Applying age-specific cutoff values for low TT levels highlighted a more pronounced AF risk reduction in participants with normal TT. MR analyses supported these observations, suggesting potential causal relationships between TT levels and both LA function and AF risk. Conclusions Our findings suggest that low TT levels are associated with reduced LA function and increased risk of AF, both observationally and genetically, indicating that serum TT could serve as a surrogate marker or even a potential causal mediator in the development of AF.Abstract tableAbstract figure