Endoscopic sphincterotomy is the established treatment for common bile duct stones. Balloon dilation offers an alternative. Prolonged dilation (300 s) with a 10 mm diameter balloon decreases the occurrence of pancreatitis after endoscopic retrograde cholangiopancreatography (ERCP). We aimed to determine the optimal duration of dilation for combined endoscopic sphincterotomy and balloon dilation for the removal of common bile duct stones. We did a multicentre, single-blinded, randomised controlled trial at 15 tertiary surgical centres in China. Eligible patients (≥18 years) with native papilla and common bile duct stones (≤1·5 cm in size and <2 cm in diameter) undergoing ERCP were randomly assigned (1:1:1:1:1) to receive balloon dilation for 0, 30, 60, 180, or 300 s after deep bile duct cannulation. Randomisation was done by an independent statistician using a computer-generated randomisation list with a block size of ten, stratified by centre. Patients and outcome assessors, but not endoscopists and investigators, were masked to treatment allocation. Balloon dilation was done with controlled radial expansion balloons according to common bile duct stone size. Stones were removed using stone retrieval balloons or baskets. The primary endpoint was overall frequency of post-ERCP pancreatitis. The primary efficacy analysis and safety analyses were done in the modified intention-to-treat population, which included all randomly assigned patients with successful cannulation, but excluded those who withdrew consent after randomisation. This study was registered with ClinicalTrials.gov, number NCT02510495, and is complete. Between July 29, 2015, and Dec 1, 2017, 3721 consecutive patients with common bile duct stones were recruited, 1718 of whom were excluded. The remaining 2003 patients underwent a small (3-5 mm) endoscopic sphincterotomy. 83 patients withdrew consent after the ERCP procedure, thus 1920 patients were included in the modified intention-to-treat analysis (0 s [n=371], 30 s [n=384], 60 s [n=388], 180 s [n=390], and 300 s [n=387]). Overall, post-ERCP pancreatitis occurred in 199 (10%) of 1920 patients (44 [12%] patients in the 0 s group, 28 [7%] in the 30 s group, 32 [8%] in the 60 s group, 36 [9%] in the 180 s group, and 59 [15%] in the 300 s group). Prolonged dilation (300 s) significantly increased the occurrence of post-ERCP pancreatitis compared with shorter balloon dilation (p=0·002). The frequency of post-ERCP pancreatitis was significantly lower in the 30, 60, and 180 s groups than in the 300 s group (relative risk [RR] 0·48, 95% CI 0·31-0·73; p=0·0005 vs the 30 s group; 0·54, 0·36-0·81; p=0·003 vs the 60 s group; 0·61, 0·41-0·89; p=0·01 vs the 180 s group). The frequency of post-ERCP pancreatitis was significantly higher in the 0 s group than the 30 s group (RR 1·62, 1·04-2·56; p=0·03). No difference in stone extraction (all ≥90%) was observed between groups. Following ERCP, 90 (5%) of 1920 patients had acute cholangitis, 14 (<1%) had acute cholecystitis, and five (<1%) had gastrointestinal bleeding, with no significant differences between groups. One (<1%) patient had Stapfer II perforation, which resolved spontaneously with conservative treatment. A balloon dilation time of 30 s for combined endoscopic sphincterotomy and balloon dilation reduced the frequency of post-ERCP pancreatitis and was determined to be the optimum dilation time for the removal of common bile duct stones. National Natural Science Foundation of China, Gansu Competitive Foundation Projects for Technology Development and Innovation.