In vitro and animal studies indicate that metformin prevents colorectal cancer (CRC). Epidemiological studies, however, have been equivocal. We undertook this study to assess whether metformin prevents CRC in individuals with type II diabetes. We performed a nested case-control study restricted to Danish citizens with type II diabetes. Data were collected from four Danish nationwide registries. Cases were type II diabetics with a primary CRC between 2000 and 2009, and controls were sampled among subjects with type II diabetes. Longterm exposure to metformin was defined by the redeeming of prescriptions for a cumulative dose of 2000 g within 5 years prior to the index date. To control for potential confounders, we used unconditional logistic regression. We generated adjusted odds ratios (OR) for the association between metformin and CRC and performed subanalyses for selected subgroups and for the dose-response relation. We identified 2088 cases and 9060 controls during the study period. The association between long-term metformin use and CRC gave an adjusted OR at 0.83 (95% CI 0.68-1.00). A protective effect on CRC with long-term use of metformin was only evident for women (OR 0.66 vs. 0.99 for men). There was a significant dose-response association of metformin use > 250 defined daily dose (DDD) and for the duration of metformin use > 1 year. We found an indication of a protective effect of long-term metformin use against CRC in type II diabetics, although this effect was only seen in women.