The present study investigated the potentially toxic heavy metal (Cu, Pb, Zn, Cr, and Cd) contamination and its ecological impact in the agricultural soil in the northeast part of Tadla plain (Morocco). A total of 60 subsurface composite samples were collected and analyzed to determine pH, soil organic matter (SOM) and texture, and heavy metal concentrations. Pollution levels were assessed by adopting enrichment factor (ef), geoaccumulation index (I geo), contamination factor (CF), pollution load index (PLI), and ecological risk index (RI). The results showed that the average concentrations of Cd, Cr, Cu, Pb, and Zn in the collected 60 topsoil samples were 0.92, 32.72, 138.10, 31.72, and 162.11 mg/kg, respectively, and followed the order Zn > Cu > Cr > Pb > Cd. These concentrations exceeded acceptable thresholds of the World Health Organization (WHO) and Food and Agriculture Organization (FAO) and local background. From the Principal Component Analysis (PCA) results showing no correlation between the soil properties and heavy metal contents, suggesting that the metal elements were of different sources, especially anthropogenic. The mean RI values of 65.68 indicated a low ecological risk and indicate that the study area is moderately to strongly pollute in the case of Zn and Cu and partly influenced by human activities. Nevertheless, this study provided important information for policymakers to propose an appropriate plan for pollution control in the agricultural Tadla plain.