Borrmann type-4 (B-4) advanced gastric cancer is challenging to diagnose through routine endoscopy, leading to a poor prognosis. The objective of this study was to develop an artificial intelligence (AI)-based system capable of detecting B-4 gastric cancers using upper endoscopy. Endoscopic images from 259 patients who were diagnosed with B-4 gastric cancer and 595 controls who had benign conditions were retrospectively collected from Seoul National University Hospital for training and testing. Internal validation involved prospectively collected endoscopic videos from eight patients with B-4 gastric cancer and 148 controls. For external validation, endoscopic images and videos from patients with B-4 gastric cancer and controls at the Seoul National University Bundang Hospital were used. To calculate patient-based accuracy, sensitivity, and specificity, a diagnosis of B-4 was made for patients in whom greater than 50% of the images were identified as B-4 gastric cancer. The accuracy of the patient-based diagnosis was highest in the internal image test set, with accuracy, sensitivity, and specificity of 93.22%, 92.86%, and 93.39%, respectively. The accuracy of the model in the internal validation videos, the external validation images, and the external validation videos was 91.03%, 91.86%, and 86.71%, respectively. Notably, in both the internal and external video sets, the AI model demonstrated 100% sensitivity for diagnosing patients who had B-4 gastric cancer. An innovative AI-based model was developed to identify B-4 gastric cancer using endoscopic images. This AI model is specialized for the highly sensitive detection of rare B-4 gastric cancer and is expected to assist clinicians in real-time endoscopy.