Objectives: Bariatric surgery can treat obesity and T2DM, but the specific mechanism is unknown. This study investigated the effect and possible mechanism of duodenal-jejunal bypass (DJB) to treat T2DM. Methods: A T2DM rat model was established using a high-fat, high-sugar diet and a low dose of streptozotocin. DJB surgery and a sham operation (SO) were performed to analyze the effects on glucose homeostasis, lipid metabolism, and inflammation changes. Furthermore, the glucagon-like peptide-1 (GLP-1) in the ileum and the markers of endoplasmic reticulum stress (ERS) in the pancreas were examined after the surgery. The insulinoma cells (INS-1) were divided into three groups; group A was cultured with a normal sugar content (11.1 mmol/L), group B was cultured with fluctuating high glucose (11.1 mmol/L alternating with 33.3 mmol/L), and group C was cultured with fluctuating high glucose and exendin-4 (100 nmol/L). The cells were continuously cultured for 7 days in complete culture medium. The viability of the INS-1 cells was then investigated using the MTT method, apoptosis was detected by flow cytometry, and the ERS markers were detected by Western blot. Results: The blood glucose, lipids, insulin, and TNF-α were significantly elevated in the T2DM model. A gradual recovery was observed in the DJB group. GLP-1 expression in the distal ileum of the DJB group was significantly higher than that in the T2DM control group (DM) and the SO group (p < 0.05), and the markers of ERS expression in the pancreases of the DJB group decreased significantly more than those of groups DM and SO (p < 0.05). Compared with group A, the cell viability in group B was decreased, and the ERS and apoptosis were increased (p < 0.05). However, compared with group B, the cell viability in group C was improved, and the ERS and apoptosis declined (p < 0.05). Conclusions: DJB can be used to treat T2DM in T2DM rats. The mechanism may be that the DJB stimulates the increased expression of GLP-1 on the far side of the ileum, and then, GLP-1 inhibits ERS in the pancreas, reducing the apoptosis of β cells to create a treatment effect in the T2DM rats.