Unsedated upper gastrointestinal endoscopy (UGE) can induce patient discomfort, mainly due to a strong gag reflex. The aim was to assess the effect of a bupivacaine lozenge as topical pharyngeal anesthetic compared with standard treatment with a lidocaine spray before UGE. Ninety-nine adult outpatients undergoing unsedated diagnostic UGE were randomized to receive either a bupivacaine lozenge (L-group, n = 51) or lidocaine spray (S-group, n = 42). Primary objective was assessment of patient discomfort including acceptance of the gag reflex during UGE. The L-group assessed the discomfort significantly lower on a visual analog scale compared with the S-group (P = 0.02). There was also a significant difference in the four-point scale assessment of the gag reflex (P = 0.03). It was evaluated as acceptable by 49% in the L-group compared with 31% in the S-group. A bupivacaine lozenge compared with a lidocaine spray proved to be a superior option as topical pharyngeal anesthetic before an UGE.