Background: Gastric cancer has a poor prognosis. Insufficient knowledge of risk factors and poor attitude and practice toward screening have caused patients to notice it in the final stages of the disease. Objectives: The purpose of this study was to determine the knowledge, attitude, and practice levels of a sample of medical sciences students and to explore the predictors of their practice regarding gastric cancer prevention. Methods: A descriptive cross-sectional study was conducted within 2021 to 2022 with 558 medical sciences students. The census method was used to select the samples. The data were collected with a demographic information questionnaire, a knowledge questionnaire about signs and symptoms, risk factors, management, and prevention of gastric cancer developed by Ghanaei in Iran, and a researcher-made questionnaire of attitude and practice. Results: The mean values of the knowledge, attitude, and practice were 19.80 ± 4.92, 69.39 ± 7.57, and 40.68 ± 4.17, respectively. There was a significant positive correlation between the practice with knowledge (r = 0.15, P < 0.001) and attitude (r = 0.21, P < 0.001) and between knowledge and attitude (r = 0.59, P < 0.001). The regression model showed that the levels of the overall attitude (β = 0.167, P < 0.001) and knowledge of prevention (β = 0.102, P = 0.032) were significantly associated with the practice of medical sciences students. Conclusions: The results indicated that attitude had the biggest contribution to predicting the practice of students, and their knowledge of prevention was the next predictor of their practice level. Therefore, holding educational programs to increase individuals’ knowledge and create a positive attitude that can, consequently, improve their practice in primary prevention is useful.