To compare the effect of fentanyl, a short-acting narcotic analgesic, with that of diazepam as intravenous premedication for endoscopy of the upper gastrointestinal tract, we allocated at random 200 consecutive outpatients requiring elective endoscopy to receive either fentanyl or diazepam; the procedure was evaluated both by the endoscopist and by the patient. The endoscopists' opinion of the ease of the procedure was significantly better for the group of patients who received fentanyl than for the group who received diazepam (P less than 0.001). The patients' opinion of the procedure was not influenced by the premedication used. No serious side effects were observed in either patient group. We concluded that fentanyl has significant advantages over diazepam as premedication for endoscopy of the upper gastrointestinal tract.