In automotive applications, precise engine speed regulation is critical for ensuring performance, efficiency, and safety. Traditional proportional-integral-derivative (PID) controllers, while widely used, often face challenges in handling the nonlinear and dynamic nature of engine systems, especially in noisy environments. To address these issues, this paper presents a PID with filter (PID-F) controller optimized using the electric eel foraging optimization (EEFO). While PID-F controllers have been explored in recent literature, this work uniquely focuses on the optimization of the PID-F controller parameters for a nonlinear engine system without performing linearization. The EEFO, inspired by the predatory behavior of electric eels, efficiently fine-tunes the controller parameters to achieve optimal performance. The proposed approach was applied to a four-cylinder spark ignition engine model, and simulation results demonstrate that the EEFO-optimized PID-F controller outperforms traditional metaheuristic algorithms, including particle swarm optimization, gravitational search algorithm, spider wasp optimizer, and artificial hummingbird algorithm, in terms of rise time, settling time, overshoot, and steady-state error. The controller also exhibited superior robustness in reference tracking, disturbance rejection, and noise handling, making it a highly effective solution for real-time automotive engine control.