Most of the world's population relies on medicinal plants as their main source of healthcare. Therefore, it is crucial to ascertain the amount of heavy metals accumulated in medicinal plants. In this study, elements (Ca, P, Mg, Na, K, S, Fe, Cu, Zn, Se, Cd, V, Cr, Ni, Ag, Be, Sr, Ba, Al, Pb, Bi, Rb, B, As, and Sb) found in Celtis tournefortii Lam and Prosopis farcta that were gathered from the Mazne sub-district of Kurdistan in Iraq were identified. Using inductively coupled plasma mass spectrometry (ICP-MS) and inductively coupled plasma optical emission spectrometry (ICP-OES), concentrations of 25 elements in the leaves, fruit (Celtis tournefortii Lam), pod, and seed (Prosopis farcta) were identified. An exploratory study of samples was conducted using principal component analysis (PCA) and hierarchical cluster analysis (HCA). For Cd, Cr, Ni, Pb, and As. The elements quantified by ppm are: Ca (3403–81948), Mg (1573–7578 ), Na (108–291), K (6481–23212), Fe (184–623), Cu (8–16), Zn (3–48), Se (0.5–33), Cd (0.11–0.40 ppm), V (1–3), Cr (2–25), Ni (2–4), Ag (0.5–1.7), Be (0.20–0.40), Sr (79.3–454), B (3–86), Al (100–738), Bi (0.7–2.30), Rb (1–7), B (0.7–2.3), As (0.1–3.9), Sb (6.60–12). All of the samples under investigation contained similar levels of phosphorus and lead (218 and 1, respectively). The samples were divided into three major categories, as demonstrated by PCA and HCA. According to the findings, the fruit of Celtis tournefortii Lam is a source of Mg, K, Cu, Cd, Cr, Be, Sr, Ba, and Rb. The seeds of Prosopis farcta had accumulated a significant level of S, Zn, Se, and Ni. The data usually implies that using these plants poses a risk to people.