In this paper, a controller is designed for a hybrid power system using a soft computing technique. The power system consists of a PV system, fuel cell, aqua electrolyzers, diesel engine generator, and a battery energy storage system. The system's frequency is controlled by a proportional-integral (PI) controller and a proportional-integral-derivative (PID) controller. A powerful optimization technique, called the Gorilla Troops Optimizer (GTO), is used to optimize the controller gains of the proposed hybrid power system. The system responses with GTO optimization-based controllers are compared with those using the Particle Swarm Optimization technique. Finally, the frequency responses show that the GTO-based controller is more effective in mitigating frequency variations in the system.