Background: Distinguishing gastric cancer from non-cancer using endoscopy has already been validated. However, distinguishing undifferentiated-type (diffuse-type) from differentiated-type (intestinal-type) cancer is also crucial for determining the indication of endoscopic resection for gastric cancer. This study aimed to evaluate on-site diagnostic performance of conventional white-light endoscopy (WLE) and magnifying narrow-band imaging (M-NBI) in determining the subtype of gastric cancer. Methods: We conducted a multicenter prospective single-arm trial. This study was registered with UMIN Clinical Trials Registry, number UMI32151. Patients who planned to undergo treatment for histologically proven cT1 gastric cancer were recruited from six tertiary care institutions. The primary and key secondary endpoints were diagnostic accuracy and specificity, respectively. The diagnostic algorithm of WLE was based on lesion color. The M-NBI algorithm was based on the microsurface and microvascular patterns. Findings: A total of 208 patients were enrolled. After protocol endoscopy, 167 gastric cancers were included in the analysis. The accuracy, sensitivity, specificity, and positive likelihood ratio of WLE for undifferentiated-type cancer were 80% (95% CI 73%–86%), 69% (53%–82%), 84% (77%–90%), and 4·4 (2·8–7·0), respectively. Those of M-NBI were 82% (75%–88%), 53% (38%–68%), 93% (87%–97%), and 7·2 (3·6–14·4), respectively. There was no significant difference in accuracy between WLE and M-NBI (p = 0·755), but specificity was significantly higher with M-NBI than with WLE (p = 0·041). Those of M-NBI combined with WLE were 81% (74%–87%), 38% (24%–54%), 97% (92%–99%), and 11·5 (4·1–32·4), respectively. Interpretation: M-NBI is more specific than WLE in distinguishing undifferentiated-type from differentiated-type gastric cancer. M-NBI combined with WLE is highly reliable (positive likelihood ratio >10) for diagnosing the subtype of gastric cancer, and optical biopsy may be introduced to determine the indication for endoscopic resection of gastric cancer. Trial Registration: UMIN Clinical Trials Registry, number UMI32151 Funding: The Yasuda Medical Foundation. Declaration of Interests: The authors declare no competing interests. Ethics Approval Statement: This multicenter, prospective, single-arm, phase II trial was conducted in accordance with the Declaration of Helsinki and Ethical Guidelines for Medical and Health Research Involving Human Subjects. The study protocol was approved by the Institutional Review Board of Osaka International Cancer Institute on December 22, 2017 (approval number: 1712226191) and each participating institution. All participants provided written informed consent.