A randomised trial was done to evaluate the impact of improved sexually transmitted disease (STD) case management at primary health care level on the incidence of HIV infection in the rural Mwanza region of Tanzania. HIV incidence was compared in six intervention communities and six pair-matched comparison communities. A random cohort of about 1000 adults aged 15-54 years from each community was surveyed at baseline and at follow-up 2 years later. Intervention consisted of establishment of an STD reference clinic, staff training, regular supply of drugs, regular supervisory visits to health facilities, and health education about STDs. 12,537 individuals were recruited. Baseline HIV prevalences were 3.8% and 4.4% in the intervention and comparison communities, respectively. At follow-up, 8845 (71%) of the cohort were seen. Of those initially seronegative, the proportions seroconverting over 2 years were 48 of 4149 (1.2%) in the intervention communities and 82 of 4400 (1.9%) in the comparison communities. HIV incidence was consistently lower in the intervention communities in all six matched pairs. Allowing for the community-randomised design and the effects of confounding factors, the estimated risk ratio was 0.58 (95% CI 0.42-0.79, p = 0.007). No change in reported sexual behaviour was observed in either group. We conclude that improved STD treatment reduced HIV incidence by about 40% in this rural population. This is the first randomised trial to demonstrate an impact of a preventive intervention on HIV incidence in a general population.