Using a nested case–control study in Ugandan individuals, we show that alternative measures of HCMV infection (IgM and IgG avidity) are associated in a dose-dependent manner with the risk of developing TB disease in samples taken up to 10 years before TB diagnosis. This evidence concerns the gene CD40LG and cytomegalovirus infection.