Metformin is a widely used drug in patients with type 2 diabetes mellitus. Metformin inhibits hepatic gluconeogenesis and increases glucose utilization in peripheral tissues. In recent years, several studies have shown that metformin is a potential therapeutic agent against cancer, alone or combined with other anticancer treatments. Metformin mainly activates the AMPK complex and regulates intracellular energy status, inhibiting the mitochondrial respiratory chain complex I and reducing the production of reactive oxygen species. Other anticancer targets of metformin are specific transcription factors inhibiting cell proliferation, promoting apoptosis and reducing drug resistance. In addition, metformin modulates tumor cells' response to anticancer treatments, favoring the activity of T cells. In diabetic patients, metformin reduces the occurrence of cancer and improves the prognosis and efficacy of anticancer treatments. In this review, we provided a comprehensive perspective of metformin as an anticancer drug.