A real-time optical biopsy, which could determine tissue histopathology, would be of extraordinary benefit to staging laparoscopy for gastric cancer with serosal invasion (T4) that requires downstage treatment. We investigated the feasibility of using multiphoton imaging to perform a real-time optical diagnosis of gastric cancer with or without serosal invasion. First, a pilot study was performed to establish the optical diagnostic features of gastric cancer with or without serosal invasion using multiphoton imaging compared with hematoxylin-eosin staining and Masson's trichrome staining. Second, a blinded study was performed to compare the diagnostic sensitivity, specificity, and accuracy of multiphoton imaging and endoscopic ultrasonography (EUS) for T4 gastric cancer. In the pilot study, multiphoton imaging revealed collagen loss and degradation and cellular and nuclear pleomorphism in gastric cancer with serosal invasion. The collagen content in gastric cancer with or without serosal invasion was 0.36 ± 0.18 and 0.79 ± 0.16 (p < 0.001), respectively. In the blinded study, the sensitivity, specificity, and accuracy of EUS and multiphoton imaging for T4 gastric cancer were 70% and 90% (p = 0.029), 66.67% and 96.67% (p = 0.003), and 68.33% and 93.33% (p = 0.001), respectively. It is feasible to use multiphoton imaging to make a real-time optical diagnosis of gastric cancer with or without serosal invasion.