This study was designed to investigate the prevalence and associated risk factors of Shigella flexneri isolated from drinking water and retail raw food samples in Peshawar, Pakistan. A total of 1,020 different samples were collected from various areas of Peshawar between January 2016 and May 2017, followed by identification of S. flexneri through biochemical, serological, and 16S rRNA gene sequencing. Potential risk factors associated with the development and spreading of S. flexneri infection were also investigated. Overall, 45 (4.41%) samples were positive for Shigella species. Among these samples, the predominant species was S. flexneri (n = 44) followed by S. boydii (n = 1). Interestingly, S. sonnei and S. dysenteriae isolates were not found in any sample. The isolation rate of S. flexneri in drinking water samples, market raw milk, and fruits/vegetables from Peshawar were 6.47%, 3.5%, and 2.9%, respectively. The phylogenetic reconstruction showed genetic diversity among three clades, as clades I and II have isolates of S. flexneri that were circulating within the drinking water, milk, fruits/vegetables, while clade III isolates were recovered from milk samples. Most of S. flexneri were detected in June to September. Potential risk factors of S. flexneri were water sources contaminated by toilet wastes (p = 0.04), surface water drainage (p = 0.0002), hospital wastes (p = 0.01), unhygienic handling (p < 0.05), and transportation of raw food (p = 0.04). In conclusion, S. flexneri isolates of closely related lineage originating from non-clinical samples might be associated with an increased human risk to shigellosis in Pakistan, as significant numbers of S. flexneri were observed in the drinking water and retail raw food samples. PRACTICAL APPLICATION: This study demonstrated the presence of S. flexneri in drinking water and retail raw food samples which seem to possess a serious threat to public health. Potential sources of food and water contamination should properly be monitored by public health authorities to reduce cases of shigellosis.