Energy generation using microbial fuel cells (MFC) and removing toxic metal ions is a potentially exciting new field of study as it has recently attracted a lot of interest in the scientific community. However, MFC technology is facing several challenges, including electron production and transportation. Therefore, the present work focuses on enhancing electron generation by extracting sugarcane waste. MFC was successfully operated in a batch mode for 79 days in the presence of 250 mg/L Pb2+ and Hg2+ ions. Sugarcane extract was regularly fed to it without interruption. On day 38, the maximum current density and power density were recorded, which were 86.84 mA/m2 and 3.89 mW/m2, respectively. The electrochemical data show that a sufficient voltage generation and biofilm formation produce gradually. The specific capacitance was found to be 11 × 10−4 F/g on day 79, indicating the steady growth of biofilm. On the other hand, Pb2+ and Hg2+ removal efficiencies were found to be 82% and 74.85%, respectively. Biological investigations such as biofilm analysis and a recent literature survey suggest that conductive-type pili species can be responsible for energy production and metal removal. The current research also explored the oxidation method of sugarcane extract by bacterial communities, as well as the metal removal mechanism. According to the parameter optimization findings, a neutral pH and waste produced extract can be an optimal condition for MFC operation.