The use of agricultural byproducts as feedstocks for the synthesis of biochar might result in the release of total petroleum hydrocarbons (TPHs) because of the presence of various plastic residues, such as plastic film mulch, gloves, and poles. TPH has been considered a critical health concern for humans worldwide. The aim of the present study was to evaluate the effect of different pyrolysis temperatures and durations on reducing the TPH concentration while synthesizing biochar using agricultural byproducts as feedstock materials. Agricultural byproducts, comprising sawdust and plastic films, were pyrolyzed as feedstocks at temperatures of 400, 500, 600, and 700 degrees C for durations of 0.5, 1, 2 and 3 h, respectively. Pyrolyzing the feedstock at 500 degrees C for 1 h and at 600 degrees C for 0.5 h significantly reduced the TPH concentration in the biochar by 98 and 91 %, respectively, compared to that at 400 degrees C for 0.5 h. The highest biochar yield was obtained at the lowest pyrolysis temperature (400 degrees C) and the shortest pyrolysis duration (0.5 h), with a subsequent steady decrease as the temperature and duration increased. These findings underscore the importance of understanding pyrolysis conditions for producing low-cost but high-quality biochar with reduced TPH contaminants and increased biochar yield. This research offers valuable insights for developing sustainable strategies for minimizing the health risks of TPH and utilizing biochar for environmental benefits.