We conducted a randomized trial to evaluate the opioid-sparing effect of an intraoperative infusion of dexmedetomidine (DEX) after craniotomy. Sixty adult patients scheduled for craniotomy were divided randomly into group A (DEX infusion at 0.5 μg/kg/h for 10 min and then adjusted to 0.2 to 0.5 μg/kg/h from tracheal intubation to incision suturing) and group B (0.9% saline infusion). Additional intravenous injections and patient-controlled analgesia with morphine were used to control postoperative pain for verbal Numerical Rating Scale scores >4. Cumulative morphine consumption, Numerical Rating Scale pain score, and the Ramsay Sedation Scale score were evaluated at 1, 2, 4, 6, 8, 12, and 24 hours; the incidence of postoperative nausea and vomiting, agitation, and respiratory depression were recorded at 24 hours after surgery. Postoperative pain scores within 12 hours and Ramsay Sedation Scale scores within 6 hours of surgery were both significantly lower in group A than in group B (P<0.001). Patients in group A required 54.4%, 43.3%, and 31.4% less cumulative morphine consumption during the first 4, 12, and 24 hours, respectively. No patient in group A and 5 patients in group B presented agitation within 1 hour after surgery. Three patients in group A and 9 patients in group B showed pruritus (P<0.001). An intraoperative infusion of DEX reduced cumulative morphine consumption and adverse effects after craniotomy.