Background: Diarrhea is a global public health issue and a leading cause of childhood malnutrition, growth disturbances, and mortality. The spread of diarrhea is closely linked to the knowledge and maintenance of personal hygiene and quality of drinking water and sanitation facilities. However, there are few such investigations and analysis in rural areas of China. This study aims to determine the association between the risk of contracting diarrhea and knowledge and practices of personal hygiene and school sanitation among rural students as well as provide a scientific basis for preventing the spread of diarrhea and other infectious diseases. A stratified cluster sampling method was used to randomly select 12 rural primary schools in each of 5 counties where the Water, Sanitation and Hygiene (WASH) Plus Program has been implemented. The counties are located in the Guangxi Zhuang autonomous region, Chongqing municipality, Guizhou province, Yunnan province, and Xinjiang Uygur autonomous region. A single fourth-grade class was randomly chosen from each of the 60 schools for observation and a questionnaire survey. The study involved a total of 2330 students. The logistic regression method was adopted to determine the factors contributing to diarrhea in rural students. The results show that male students accounted for 49.40% (n = 1151) of the 2330 research subjects; the average age of the students was 9.9 ± 0.3 years. Approximately 33.09% of the students suffered from diarrhea in the three months leading up to the survey. The odds ratios (ORs) of students who did not know that “diarrhea can be prevented by washing fruits before eating them raw and not drinking untreated water” (OR: 1.303, 95% confidence interval [CI]: 1.063, 1.597) and that “the disease can be prevented by washing hands before meals and after going to the toilet” (OR: 1.522, 95% CI: 1.207, 1.920) were higher than those who knew the above stated facts. Students who “have drunk untreated water at school” (OR: 1.584, 95% CI: 1.268, 1.978), “have drunk untreated water at home” (OR: 1.643, 95% CI: 1.319, 2.048), and “did not wash hands before every meal” (OR: 1.490, 95% CI: 1.120, 1.983) were at a higher risk of contracting diarrhea than those who drank treated water at school and at home and washed their hands before every meal. Diarrhea was more likely to affect students who attended schools with unclean and poorly maintained toilets (OR: 1.586, 95% CI: 1.261, 1.995) or toilets with flies (OR: 1.383, 95% CI: 1.114, 1.717) and without adequate drinking water facilities (OR: 1.407, 95% CI: 1.009, 1.962). The knowledge of methods to maintain personal hygiene, general hygiene practices, and school sanitation are the three major risk factors that account for the spread of diarrhea among rural students from five western provinces (municipalities and autonomous regions) of China. Therefore, to prevent such diseases and maintain health, it is important to provide students with health education, help them develop good hygiene habits, ensure the provision of clean water at schools, and improve the overall school environments.