Designing control systems for islanded microgrids poses significant challenges due to the absence of inertia and parameter uncertainties. These factors increase the complexity of traditional methods when applied to highly nonlinear and interdependent systems. To address this issue, a novel Electric Eel Foraging Optimization (EEFO) technique is proposed for tuning control parameters within a hierarchical structure of primary and secondary control levels. The control system employs proportional resonant (PR) controllers for voltage and current regulation, alongside a synchronization loop to enable seamless grid reconnection. Comparative analysis with Particle Swarm Optimization (PSO) and Grey Wolf Optimization (GWO) confirms EEFO's superior convergence speed and solution quality performance. Simulation results using MATLAB/SIMULINK demonstrate effective active power sharing, minimal overshoot and settling times for voltage (2.4%, 0.25 s) and frequency (0.42%, 0.53 s), and seamless grid reconnection. Experimental validation using hardware-in-the-loop (HIL) real-time emulation further verifies the feasibility and robustness of the proposed approach for practical microgrid applications.