Pain control and stabilizing hemodynamic indices are serious medical challenges, especially in anesthesia. Laparoscopic surgery is increasing in the world, and cholecystectomy surgery is no exception. This study investigated the effect of intravenous (IV) magnesium sulfate injection on intraoperative end-tidal CO2 (ETCO2) levels and postoperative pain in laparoscopic cholecystectomy. This is a clinical trial. The sample size was calculated to be 64 people who were selected among the patients who were candidates for laparoscopic surgery by convenience sampling. They were randomly assigned to intervention and control groups. The intervention group received magnesium sulfate (50 mg/kg) and normal saline (100 mL) within 1 h. The control group only received normal saline (100 mL). Systolic and diastolic blood pressures, ETCO2 level, heart rate, arterial oxygen saturation, pain level, and narcotic analgesics in recovery were measured 2, 6, 12, and 24 h after surgery. The data were analyzed using 1-way analysis of variance (ANOVA) and repeated measures analysis. The mean of systolic blood pressure and ETCO2 during recovery in the intervention group were less than the control group (P = 0.029 and P = 0.015). In the intervention group, analgesic consumption in recovery and 6 h after surgery was less than the control group (P < 0.001). The mean pain score in the intervention group in recovery and 2, 6 (P < 0.001), and 12 h (P = 0.038) after surgery was significantly lower than the control group. Magnesium sulfate can be a suitable and safe supplement to reduce pain after surgery and reduce the use of narcotics. The current conclusion should be investigated on a larger scale of patients, with extended monitoring for postoperative pain over a longer period of time.