Background Magnifying endoscopy with narrow band imaging (M-NBI) has been applied to examine early gastric cancer by observing microvascular architecture and microsurface structure of gastric mucosal lesions. However, the diagnostic efficacy of non-experts in differentiating early gastric cancer from non-cancerous lesions by M-NBI remained far from satisfactory. In this study, we developed a new system based on convolutional neural network (CNN) to analyze gastric mucosal lesions observed by M-NBI. Methods A total of 386 images of non-cancerous lesions and 1702 images of early gastric cancer were collected to train and establish a CNN model (Inception-v3). Then a total of 341 endoscopic images (171 non-cancerous lesions and 170 early gastric cancer) were selected to evaluate the diagnostic capabilities of CNN and endoscopists. Primary outcome measures included diagnostic accuracy, sensitivity, specificity, positive predictive value, and negative predictive value. Results The sensitivity, specificity, and accuracy of CNN system in the diagnosis of early gastric cancer were 91.18%, 90.64%, and 90.91%, respectively. No significant difference was spotted in the specificity and accuracy of diagnosis between CNN and experts. However, the diagnostic sensitivity of CNN was significantly higher than that of the experts. Furthermore, the diagnostic sensitivity, specificity and accuracy of CNN were significantly higher than those of the non-experts. Conclusions Our CNN system showed high accuracy, sensitivity and specificity in the diagnosis of early gastric cancer. It is anticipated that more progress will be made in optimization of the CNN diagnostic system and further development of artificial intelligence in the medical field.