Today, renewable energy systems like photovoltaic system are widely used in various applications. Among the different types of microgrids, hybrid microgrids are the most used type, therefore, inverters should be used to exchange power between DC and AC sides. According to the existing economic issues, extracting the maximum possible power from these systems are an important issue. This paper presents a new neuro-fuzzy controller for achieving maximum power point tracking (MPPT) in a grid-connected PV system under partially shaded conditions. This controller uses the Gravity Search Algorithm (GSA) to track the global maximum power point (GMPP) of the presented grid-connected PV system. The method controls the grid-connected inverter at the desired voltage to achieve maximum power after receiving its required specifications from the system. The Matlab/Simulink software is used to evaluate the performance of the proposed method. The results show that the proposed method can track the maximum power point under uniform and partial shading conditions with high speed and accuracy. Specifically, the proposed algorithm improves the tracking speed and increases the power output compared to traditional methods. The neuro-fuzzy controller's adaptive capabilities allow it to respond efficiently to dynamic changes in shading, ensuring stable and optimal power output. These advantages make the proposed method a significant improvement over existing MPPT techniques.