This study compared the role of octreotide and proton pump inhibitor (PPI) in preventing acute pancreatitis after endoscopic retrograde cholangiopancreatography (ERCP). The 320 patients who received ERCP from January 2019 to June 2022 were randomly and evenly divided into octreotide, PPI, combined treatment and control groups. The incidence of post-ERCP acute pancreatitis (PEP) and hyperamylasemia was counted. The incidence of PEP and hyperamylasemia after surgery differed significantly among all groups. For incidence of PEP, it was similar in the control, octreotide and PPI groups (12.50%, 8.75% and 10.00%), all of which were higher than that of the combined treatment group (1.25%). The incidence of hyperamylasemia was similar between the octreotide and PPI groups (12.50% and 13.75%), both decreased compared with the control group (32.50%), and further lowered in the combined treatment group (8.75%), and all differences were statistically significant (p < 0.05). For patients with choledocholithiasis, the incidence of hyperamylasemia in the combined treatment group was lower than that in the other three groups (8.33%, 31.25%, 21.43% and 16.67%) after intervention, while there were no significant differences in the incidence of PEP and hyperamylasemia in patients with cholangiocarcinoma, pancreatic head carcinoma and other lesions. In conclusion, preoperative application of octreotide or PPI alone has a slight effect on preventing PEP and hyperamylasemia after ERCP, and their combination is dramatically effective in preventing PEP.