Background: Adequate patient sedation is mandatory for advanced endoscopic procedures such as ERCP and EUS. Aim: To evaluate the effectiveness and safety of ketamine in difficult to sedate patients undergoing advanced endoscopic procedures. Methods: This was a prospective, randomized trial of all patients undergoing ERCP or EUS who were not adequately sedated despite administration of meperidine 50 mg, midazolam 5 mg and diazepam 5 mg. Patients during endoscopy were then randomized to receive either intravenous ketamine (20 mg) every 5 min or continue to receive standard sedation using meperidine and diazepam. Results: Of 175 patients, 82 were randomized to receive ketamine and 93 standard sedatives. Compared with standard sedation, qualitative physician rating (P < 0.0001) and depth of sedation (P < 0.001) were superior in the ketamine group with shorter recovery times (P < 0.0001). Both patient discomfort and sedation-related technical difficulty were significantly less among patients randomized to receive ketamine (P < 0.0001). More patients in the standard sedation group were crossed-over to the ketamine group due to sedation failure (35.5 vs. 3.7%, P < 0.0001). Nine patients who received ketamine, developed adverse events that were managed conservatively. Conclusions: Ketamine is a useful adjunct to conscious sedation in patients who are difficult to sedate. Its use results in better quality and depth of sedation with shorter recovery times than patients sedated using benzodiazepines and meperidine alone. Further prospective studies evaluating the effectiveness and safety of ketamine for endoscopic sedation are needed. © 2007 The Authors.