The liver is crucial for the maintenance of normal glucose homeostasis - it produces glucose during fasting and stores glucose postprandially. However, these hepatic processes are dysregulated in type 1 and type 2 diabetes mellitus, and this imbalance contributes to hyperglycaemia in the fasted and postprandial states. Net hepatic glucose production is the summation of glucose fluxes from gluconeogenesis, glycogenolysis, glycogen synthesis, glycolysis and other pathways. In this Review, we discuss the in vivo regulation of these hepatic glucose fluxes. In particular, we highlight the importance of indirect (extrahepatic) control of hepatic gluconeogenesis and direct (hepatic) control of hepatic glycogen metabolism. We also propose a mechanism for the progression of subclinical hepatic insulin resistance to overt fasting hyperglycaemia in type 2 diabetes mellitus. Insights into the control of hepatic gluconeogenesis by metformin and insulin and into the role of lipid-induced hepatic insulin resistance in modifying gluconeogenic and net hepatic glycogen synthetic flux are also discussed. Finally, we consider the therapeutic potential of strategies that target hepatosteatosis, hyperglucagonaemia and adipose lipolysis.