An increase in liver gluconeogenesis is an important pathological phenomenon in type 2 diabetes mellitus (T2DM) and oxymatrine is an effective natural drug used for T2DM treatment. The present study aimed to explore the effect of oxymatrine on gluconeogenesis and elucidate the underlying mechanism. Male Sprague-Dawley rats were treated with a high-fat diet and streptozotocin for 4 weeks to induce T2DM, and HepG2 cells were treated with 55 mM glucose to simulate T2DM in vitro. T2DM rats were treated with oxymatrine (10 or 20 mg/kg weight) or metformin for 4 weeks, and HepG2 cells were treated with oxymatrine (0.1 or 1 µM), metformin (0.1 µM), or oxymatrine combined with MK-2206 (AKT inhibitor) for 24 h. Fasting blood glucose and insulin sensitivity of rats were measured to evaluate insulin resistance. Glucose production and uptake ability were measured to evaluate gluconeogenesis in HepG2 cells, and the expression of related genes was detected to explore the molecular mechanism. Additionally, the body weight, liver weight and liver index were measured and hematoxylin and eosin staining was performed to evaluate the effects of the disease. The fasting glucose levels of T2DM rats was 16.5 mmol/l, whereas in the control rats, it was 6.1 mmol/l. Decreased insulin sensitivity (K-value, 0.2), body weight loss (weight, 300 g), liver weight gain, liver index increase (value, 48) and morphological changes were observed in T2DM rats, accompanied by reduced AKT phosphorylation, and upregulated expression of phosphoenolpyruvate carboxykinase (PEPCK) and glucose-6-phosphatase (G6Pase). High-glucose treatment significantly increased glucose production and decreased glucose uptake in HepG2 cells, concomitant with a decrease in AKT phosphorylation and increase of PEPCK and G6Pase expression. In vivo, oxymatrine dose-dependently increased the sensitivity of T2DM rats to insulin, increased AKT phosphorylation and decreased PEPCK and G6Pase expression in the liver, and reversed the liver morphological changes. In vitro, oxymatrine dose-dependently increased AKT phosphorylation and glucose uptake of HepG2 cells subjected to high-glucose treatment, which was accompanied by inhibition of the expression of the gluconeogenesis-related genes, PEPCK and G6Pase. MK-2206 significantly inhibited the protective effects of oxymatrine in high-glucose-treated cells. These data indicated that oxymatrine can effectively prevent insulin resistance and gluconeogenesis, and its mechanism may be at least partly associated with the regulation of PEPCK and G6Pase expression and AKT phosphorylation in the liver.