Trimethoprim resistance is increasingly prevalent in community-acquired urinary infections. The objective of this study was to evaluate the association between exposure to community-prescribed trimethoprim and other risk factors in subjects and subsequent trimethoprim-resistant urinary tract infection. The design was a nested case-control study using a record-linkage database. Study subjects submitted a urine sample to the Ninewells Hospital Laboratory between July 1993 and December 1995. Antibiotic exposure in subjects with trimethoprim-resistant isolates (cases) was compared with antibiotic exposure in subjects with trimethoprim-susceptible isolates (controls). Study subjects were drawn from the catchment area of a large teaching hospital in Tayside, Scotland. There were 13765 males and females aged 1-106 years who submitted their first urine sample for culture during the study period. After adjustment for significant risk factors and confounding variables, logistic regression analysis showed exposure to trimethoprim [odds ratio (OR) 4.35] or any antibiotic other than trimethoprim (OR 1.32) to be predictive of resistance. The growth of Proteus spp. (OR 115.14) and bacterial growth other than Escherichia coli and Proteus spp. (OR 2.83) were also predictor variables. Hospitalization in the previous 6 months was not independently associated with trimethoprim resistance. In conclusion, trimethoprim resistance was independently associated with exposure to trimethoprim and to antibiotics other than trimethoprim. Reduction in trimethoprim prescribing alone may not reduce the prevalence of trimethoprim resistance.