This study proposes a control algorithm based on synchronous reference frame theory with unit templates instead of a phase locked loop for grid-connected photovoltaic (PV) solar system, comprising solar PV panels, DC-DC converter, controller for maximum power point tracking, resistance capacitance ripple filter, insulated-gate bipolar transistor based controller, interfacing inductor, linear and nonlinear loads. The dynamic performance of the grid connected solar system depends on the effect operation of the control algorithm, comprising two proportional-integral controllers. These controllers estimate the reference solar-grid currents, which in turn generate pulses for the three-leg voltage source converter. The grey wolf optimization algorithm is used to optimize the controller gains of the proportional-integral controllers, resulting in excellent performance compared to that of existing optimization algorithms. The compensation for neutral current is provided by a star-delta transformer (non-isolated), and the proposed solar PV grid system provides zero voltage regulation and eliminates harmonics, in addition to load balancing. Maximum power extraction from the solar panel is achieved using the incremental conductance algorithm for the DC-DC converter supplying solar power to the DC bus capacitor, which in turn supplies this power to the grid with improved dynamics and quality. The solar system along with the control algorithm and controller is modeled using Simulink in Matlab 2019.