In a randomized, double-blind, prospective study, we investigated whether an intraoperative high versus low dose of remifentanil increased postoperative hyperalgesia and whether magnesium can prevent remifentanil-induced hyperalgesia. Ninety patients undergoing thyroidectomy were randomly assigned to 1 of 3 groups. Remifentanil was intraoperatively infused at 0.05 μg/kg/min (group LO) or 0.2 μg/kg/min (groups HI and HM). Patients in group HM received MgSO(4) 30 mg/kg at induction followed by an intraoperative infusion of 10 mg/kg/h. Mechanical pain thresholds on the forearm and periincisional area were assessed by von Frey filament the evening before surgery and postoperatively at 24 and 48 hours. Pain measured on a verbal numerical rating scale (VNRS) (0-10) and additional analgesics were recorded in the postanesthesia care unit postoperatively at 6, 24, and 48 hours. There was a significantly greater decrease in pain threshold on the periincisional area at 24 and 48 hours postoperatively in group HI, as compared with the other 2 groups. The 95% confidence intervals for the mean difference in pain thresholds on the periincisional area at 24 and 48 hours postoperatively were 0.31 to 1.11 and 0.36 to 1.14 for group HI versus group LO, 0.45 to 1.26 and 0.54 to 1.32 for group HI versus group HM (values are log(10) of force in milligrams). The change in pain threshold on the forearm was similar among the groups. Group HI had significantly higher VNRS scores (median [interquartile range], 3 [2-4]) than group LO (2 [1-3] and group HM (2 [1-3]) at 48 hours postoperatively. The 95% confidence intervals for median difference in VNRS score at 48 hours postoperatively were 1 to 2 for group HI versus group LO and 0 to 2 for group HI versus group HM. There were no significant differences in the number of patients who requested rescue analgesics in the postoperative anesthesia care unit and general ward during 48 hours postoperatively among the 3 groups. A relatively high dose of intraoperative remifentanil enhances periincisional hyperalgesia. Intraoperative MgSO(4) prevents remifentanil-induced hyperalgesia. However, hyperalgesia did not reach clinical relevance in terms of postoperative pain or analgesic consumption in patients undergoing thyroidectomy.