Objective To compare the social and demographic profiles of patients who receive statin treatment after myocardial infarction and patients included in randomised trials. To estimate the effect of statin use in community based patients on subsequent all cause mortality and cardiovascular recurrence, contrasting effects with trial patients. Design Observational cohort study using a record linkage database. Setting Tayside, Scotland (population size and characteristics: about 400 000, mixed urban and rural). Subjects 4892 patients were discharged from hospital after their first myocardial infarction between January 1993 and December 2001. 2463 (50.3%) were taking statins during an average follow-up of 3.7 years (3.1% in 1993 and 62.9% in 2001). Main outcome measures All cause mortality and recurrence of cardiovascular events. Results 319 deaths occurred in the statin treated group (age adjusted rate 4.1 per 100 person years, 95% confidence interval 3.2 to 4.9), and 1200 in the statin untreated group (12.7 per 100 person years, 11.1 to 14.3). More older people and women were represented in the population of patients treated with statins than among those recruited into clinical trials (mean age 67.8 v 59.8; women 39.6% v 16.9%, respectively). The effects of statins in routine clinical practice were consistent with, and similar to, those reported in clinical trials (adjusted hazard ratio for all cause mortality 0.69, 95% confidence interval 0.59 to 0.80; adjusted hazard ratio for cardiovascular recurrence 0.82, 0.71 to 0.95). Conclusions The community effectiveness of statins in those groups that were not well represented in clinical trials was similar to the efficacy of statins in these trials.