Alternative energy sources are needed for a sustainable world due to rapidly increasing energy consumption, fossil fuels, and greenhouse gases worldwide. A hybrid renewable energy system (HRES) must be optimally dimensioned to be responsive to sudden load changes and cost-effective. In this study, the aim is to reduce the carbon emissions of a university campus by generating electricity from a hybrid energy production system with solar panels, wind turbine, a diesel generator, and battery components. On the university campus where the hybrid energy system will be installed, the ambient temperature, solar radiation, wind speed, and load demands have been recorded in our database. Optimization algorithms were used to select the power values of the system components to be installed using these data in an efficient and inexpensive manner according to the ambient conditions. For optimal sizing of HRES components, gray wolf optimizer combined with cuckoo search (GWOCS) technique was investigated using MATLAB/Simulink. In this way, it has been tried to increase their efficiency by combining current optimization techniques. The cornerstone of our optimization efforts for both on-grid and off-grid models pivots on a constellation of critical decision variables: the power harvested from wind turbines, the productivity of solar panels, the capacity of battery storage, and the power contribution of diesel generators. In our pursuit of minimizing the annual cost metric, we employ a tailor-made function, meticulously upholding an array of constraints, such as the quotient of renewable energy and the potential risk of power disruption. A robust energy management system is integral to our design, orchestrating the delicate power flow balance among micro-grid components—vital for satisfying energy demand. Upon analyzing the outcomes of the study, it is apparent that the proposed Scenario 1 HRES effectively utilizes solar and battery components within the off-grid model, surpassing the efficiency of four other hybrid scenarios under consideration. Regarding optimization processes, the off-grid model exhibits superior results with the implementation of the GWOCS algorithm, delivering faster and more reliable solutions relative to other methodologies. Conversely, the optimization of the on-grid model reaches its optimal performance with the application of the cuckoo search algorithm. A comprehensive comparison from both technical and economic view points suggests the on-grid model as the most feasible and suitable choice. Upon completion of the optimization process, the load demand is catered to by a combination of a 2963.827-kW solar panel, a 201.8896-kW battery, and an additional purchase of 821.9 MWh from the grid. Additionally, an energy surplus sale of 1379.8 MWh to the grid culminates in an annual cost of system (ACS) of 475782.8240 USD, a total net present cost of 4815520.2794 USD, and a levelized cost of energy of 0.12754 USD/kWh. Solar panels cover the entire system, and the renewable energy fraction is 100%.