Background Despite the amount of published studies on the subject, controversy still exists about the effect of coffee drinking on the occurrence of coronary heart disease. In general, epidemiological studies do not support the belief that it is a major risk factor. Design A community-based case–control study was conducted. Methods A random sample of men aged 40 years and over with no previous myocardial infarction was compared with patients with a first acute myocardial infarction (AMI). A structured questionnaire was used to collect information on sociodemographic characteristics, personal and family medical history and lifestyles. Dietary data were obtained by a food frequency questionnaire. Odds ratios were calculated by unconditional logistic regression. After exclusions, 290 cases and 364 controls were considered in the final analysis. Results Coffee drinking is a widespread habit in this population, and most individuals did not change their habit throughout life. Most participants reported the consumption of moderate amounts of coffee (<25% drank more than four cups a day) and espresso was by far the most commonly used brewing. The crude odds ratio for having ever drunk coffee regularly was 0.5 (95% confidence interval 0.3–1.1). However, there was a significant effect–measure modification by family history of AMI ( P=0.02). Conclusions The results suggest different susceptibility to coffee drinking, such that coffee drinking was positively although not significantly associated with an increased risk of AMI in men with a family history of AMI, whereas there was a significant inverse association with the occurrence of myocardial infarction among men with no family history of AMI.