Calcium/calmodulin-dependent protein kinase kinase 2 (CaMKK2) and mitochondrial sodium/calcium exchanger protein (NCLX) are key regulatory factors in calcium homeostasis. Finding natural drugs that target regulators of calcium homeostasis is critical. Dihydroartemisinin (DHA) is considered to have anticancer effects. The present study aimed to investigate the mechanism of DHA in regulating liver cancer migration and invasion. The present study used HepG2 and HuH-7 cells and overexpressed CaMKK2 and knocked down CaMKK2 and NCLX. The antiproliferative activity of DHA on liver cancer cells was assessed through colony formation and EdU assays. Cell apoptosis was detected through YO-PRO-1/PI staining. The levels of reactive oxygen species (ROS) were measured using a ROS detection kit (DCFH-DA fluorescent probe). Cell migratory and invasive abilities were examined using wound healing and Transwell assays. The ATP production of liver cancer cells was detected using ATP fluorescent probes. Cell microfilaments were monitored for changes using Actin-Tracker Green-488. The effects of DHA on the expression of CaMKK2, NCLX, sodium/potassium-transporting ATPase subunit α-1 (ATP1A1) and ATP synthase subunit d, mitochondrial (ATP5H) were determined by western blotting and reverse transcription-quantitative PCR. The results revealed that DHA significantly inhibited proliferation, reduced ROS levels and promoted apoptosis in liver cancer cells. CaMKK2 overexpression significantly enhanced the invasive and migratory ability of liver cancer cells, whereas DHA inhibited the pro-migratory effects of CaMKK2 overexpression. DHA significantly reduced the mitochondrial ATP production and altered the arrangement of microfilaments in liver cancer cells. In addition, DHA significantly decreased the expression of CaMKK2, NCLX, ATP1A1 and ATP5H. Furthermore, by knockdown experiments of NCLX the results demonstrated that CaMKK2 downregulated the expression of ATP1A1 and ATP5H in liver cancer cells through NCLX. In conclusion, DHA may reduce ATP synthase production via the CaMKK2/NCLX signaling pathway to inhibit the invasive phenotype of liver cancer cells. It is essential to further investigate the effectiveness of DHA in the anticancer mechanism of liver cancer cells.