Vegetables cultivated near roads absorb toxic metals from polluted soil, which enter into the human body through the food chain and cause serious health problems to humans. The present study investigated the contamination level of lead (Pb) and nickel (Ni) in soils and vegetables grown along the roadside of District Swat, Pakistan, and the health risks associated with the consumption of the tested vegetables have been investigated. The plant samples were collected from the cultivated field within a 120-meter range from the roadside. Spinacia oleracea, Allium cepa, Rumex dentatus, and Trachyspermum ammi were selected based on their importance as vegetables. In results, Pb concentration was higher in plants located at the distance between 0-10 m away from the roadside than the WHO permissible limit. In such plants, Pb concentration was higher than Ni. Rumex dentatus contained the highest concentration of Pb among the tested vegetables while Ni concentration was highest in Trachyspermum ammi as compared to other plants. Concentration and accumulation of both the metals decreased in soil and plants with increasing distance from the road. Similarly, target hazard quotient values noted for Pb and Ni were greater than unity, which shows that there is a potential risk associated with the consumption of tested vegetables near the road. Moreover, the values of target cancer risk were greater than 0.0001, which shows that there is a risk of cancer with the consumption of tested vegetables. In conclusion, the consumption of the tested vegetables was very dangerous as it may lead to higher risks of cancer.