Prolonged consumption of foods containing toxic metals can elevate the risk of noncommunicable diseases, including chronic kidney disease of uncertain etiology (CKDu). Despite the increasing number of CKDu cases in Maradankulama and Mahakanadrawa Grama Niladhari Divisions (GN) in Sri Lanka, no prior studies have examined the accumulation of heavy metal(loid)s and their potential association with CKDu prevalence. Furthermore, there is an absence of comprehensive analyses using chemometric techniques such as PCA and hierarchical studies regarding CKDu and heavy metal contamination in Sri Lanka. This study aims to provide initial insights into the accumulation and potential pathways of toxic metals in staple foods within local diets and their subsequent presence in the agricultural environment of examined GNs. Cr, Cd, As, and Ni concentrations in analyzed foods were within permissible limits (MPLs), whereas Pb levels exceeded MPLs in rice (Oryza sativa), gotukola (Centella asiatica), lime (Citrus crenatifolia), and inland fish (Etroplus suratensis). High target hazard quotient (THQt) values in polished rice suggest possible health risks with prolonged intake. Hierarchical analysis suggested a common source of Pb accumulation. PCA and hierarchical clustering revealed the intricate connection between As and Cd, with their concurrent clustering in samples suggesting a potential common origin. This indicates that while individual concentrations comply with acceptable standards, the potential synergistic effects of Cd and As accumulation might pose elevated health risks. Further, the gut tissues of inland fish exhibited pronounced metal concentrations and significant (p < 0.05) positive correlations with toxic metals in the tank sediments suggesting a diet-based bioaccumulation pathway through sediments.