Anaerobic co-digestion of waste activated sludge (WAS) with food waste (FW) represents a viable and effective approach to energy recovery and pollutant elimination. Little is known about the effect of alternating change of acid/alkaline conditions on pathogens inactivation within the co-digestion system of WAS and FW. In this study, pH changes during batch anaerobic co-digestion with WAS/FW ratios varying from 0.4 to 8, and their impact on pathogen inactivation were investigated using Escherichia coli as a model pathogen. At WAS/FW=1 and 2, serious acidification (pH<5.5) was effectively mitigated, and the pH transitioned from 6.4 during the acidogenesis stage to >8.5 during the methanogenesis stage. WAS/FW=1 achieved the highest methane yield (256.7 mL/g VS), which was 38.9 % greater than that in their mono-digestion scenario. A 2.37 − 3.87 log10 reduction in E. coli abundance occurred in all tested conditions during the acidogenesis stage, and a further reduction to an undetectable level was achieved only in WAS/FW reaching 1 subsequently. Low pH induced free volatile fatty acids dominated E. coli inactivation during the acidogenesis stage. During the methanogenesis stage, the combined action of OH− and the resultant free ammonia contributed to E. coli inactivation with free ammonia being more efficient in its action. This research contributes to the advancement of sustainable and secure management of organic wastes.