The optimal power flow issue (OPFI) can be solved in this work using the recently developed algorithm, gorilla troops algorithm (GTA). The goal of OPFI is to reduce numerous functions such as minimizing fuel costs, emissions, and power losses and improving the voltage stability related to electric power networks (EPNs). The GTA is inspired by gorillas’ social habits, which include migration to a strange region, migration toward a specified spot, traveling to other gorillas, competing for adult females, and escorting the silverback. The developed GTA is tested with and without the inclusion of the Thyristor-Controlled Series Capacitor (TCSC) devices in the system. The proposed GTA is applied on a practical Egyptian West Delta-EPN (WD-EPN) and the standard IEEE 57-bus EPN and with and without the inclusion of the TCSC devices to appraise the GTA algorithm’s performance in the OPFI. In addition, the proposed GTA is applied on a large-scale IEEE 118 bus system with higher outperformance compared to particle swarm optimization. The results illustrate that the fuel costs, emissions, voltage stability, and power losses are reduced for the standard IEEE 57-bus EPN with and without TCSC devices by a percentage of (18.847% and 18.818%), (59% and 58.97%), (13.405% and 11.507%), and (64.337% and 65.178%), respectively, while fuel costs, emissions, voltage stability, and power losses are reduced for WD-EPN with and without TCSC devices by a percentage of (8.547%, 8.565%), (13.641%, 13.6%), and (61.949%, 61.954%), respectively. A comparison study is conducted to demonstrate the GTA’s effectiveness when compared with other recently developed algorithms such as improved Salp Swarm Algorithm, quasi-reflection jellyfish search, Salp Swarm Algorithm, improved heap-based algorithm, bat search algorithm, social network search algorithm, electromagnetic field optimization, and other well-known algorithms as well. According to the comparison with these algorithms, the GTA demonstrates the best results among the attained results.