Objective Type 2 diabetes mellitus is associated with a higher risk of hepatocellular carcinoma (HCC), which is attenuated by the use of metformin. However, there are no studies addressing the effect of metformin on hepatocarcinoma cells from the antitumoural perspective. Design In the nationwide case-control study, the authors recruited 97 430 HCC patients and 194 860 age-, gender- and physician visit date-matched controls. The chemopreventive effects of metformin were examined by multivariate analysis and stratified analysis. The in vitro effects of metformin on cell proliferation and cell cycle were studied in HepG2 and Hep3B hepatoma cell lines. Results The OR of diabetes in HCC patients was 2.29 (95% CI 2.25 to 2.35, p<0.001). Each incremental year increase in metformin use resulted in 7% reduction in the risk of HCC in diabetic patients (adjusted OR=0.93, 95% CI 0.91 to 0.94, p<0.0001). In the multivariate stratified analysis, metformin use was associated with a reduced risk of HCC in diabetic patients in nearly all subgroups. Cell line studies showed that metformin inhibits hepatocyte proliferation and induces cell cycle arrest at G0/G1 phase via AMP-activated protein kinase and its upstream kinase LKB1 to upregulate p21/Cip1 and p27/Kip1 and downregulate cyclin D1 in a dose-dependent manner, but independent of p53. Combined treatment of oral metformin with doxorubicin functioned more efficiently than either agent alone, in vivo. Conclusions Use of metformin is associated with a decreased risk of HCC in diabetic patients in a dose-dependent manner, via inhibition of hepatoma cells proliferation and induction of cell cycle arrest at G0/G1 phase.