Objective: Remimazolam is a novel benzodiazepine sedative that provides effective sedation, stable haemodynamics, and minimal adverse effects during intravenous general anaesthesia. The aim of this study was to determine the 50% effective dose (ED50) of remimazolam combined with different doses of esketamine for painless gastroscopy and to evaluate the efficacy and safety of this combination. Methods: This was a randomised, double-blind, up-and-down sequential allocation study. Patients undergoing painless gastroscopy who met all the inclusion criteria and did not meet any of the exclusion criteria were randomised in a 1:1:1 ratio into the ES0 group (0 mg/kg of esketamine), ES1 group (0.2 mg/kg of esketamine), and ES2 group (0.4 mg/kg of esketamine). The initial dose of remimazolam was 0.3 mg/kg in each group, with the dose increased or decreased by 0.05 mg/kg for the subsequent patient based on the success or failure of sedation in the previous patient. The trial was concluded when seven successful failure crossovers were achieved. The ED50 and 95% confidence intervals (CI) of remimazolam were calculated using Probit regression. Haemodynamic parameters, time to induction of anaesthesia, time to gastroscopy, time to awakening from anaesthesia, and adverse events were recorded. Results: A total of 59 patients were included in the final analysis: 19 in the ES0 group, 23 in the ES1 group, and 17 in the ES2 group. The ED50 (95% CI) of remimazolam in the ES0, ES1, and ES2 groups was 0.344 (0.302–0.389) mg/kg, 0.289 (0.249–0.328) mg/kg, and 0.193 (0.145–0.239) mg/kg, respectively. Additionally, the ES1 and ES2 groups exhibited more stable haemodynamics compared to the ES0 group. However, the ES1 and ES2 groups had significantly longer recovery times than the ES0 group. The incidence of hypotension was higher in the ES0 group compared to the ES1 and ES2 groups. Conclusion: The ED50 of remimazolam combined with 0 mg/kg, 0.2 mg/kg, and 0.4 mg/kg of esketamine for induction of anaesthesia during painless gastroscopy was 0.344 mg/kg, 0.289 mg/kg, and 0.193 mg/kg, respectively. Combining esketamine with remimazolam for induction of anaesthesia during painless gastroscopy offers advantages in terms of haemodynamic stability and reduced adverse effects.