The diagnosis of autoimmune pancreatitis (AIP) is challenging. Sonographic and cross-sectional imaging findings of AIP closely mimic pancreatic ductal adenocarcinoma (PDAC) and techniques for tissue sampling of AIP are suboptimal. These limitations often result in delayed or failed diagnosis, which negatively impact patient management and outcomes. This study aimed to create an endoscopic ultrasound (EUS)-based convolutional neural network (CNN) model trained to differentiate AIP from PDAC, chronic pancreatitis (CP) and normal pancreas (NP), with sufficient performance to analyse EUS video in real time.A database of still image and video data obtained from EUS examinations of cases of AIP, PDAC, CP and NP was used to develop a CNN. Occlusion heatmap analysis was used to identify sonographic features the CNN valued when differentiating AIP from PDAC.From 583 patients (146 AIP, 292 PDAC, 72 CP and 73 NP), a total of 1 174 461 unique EUS images were extracted. For video data, the CNN processed 955 EUS frames per second and was: 99% sensitive, 98% specific for distinguishing AIP from NP; 94% sensitive, 71% specific for distinguishing AIP from CP; 90% sensitive, 93% specific for distinguishing AIP from PDAC; and 90% sensitive, 85% specific for distinguishing AIP from all studied conditions (ie, PDAC, CP and NP).The developed EUS-CNN model accurately differentiated AIP from PDAC and benign pancreatic conditions, thereby offering the capability of earlier and more accurate diagnosis. Use of this model offers the potential for more timely and appropriate patient care and improved outcome.