To ensure the photovoltaic (PV) system can still output maximum power under changing environmental conditions, a modified hill climbing algorithm is proposed. The algorithm uses a variable step-size strategy to reduce the steady-state oscillations and prevent operating point from diverging away from the maximum power point by introducing boundary conditions. To verify its effectiveness, the proposed algorithm is compared with the conventional and adaptive hill climbing method under the environmental condition of irradiance step change and gradual change. The simulation results show that the proposed algorithm can increase the dynamic response speed of the PV system by 75% under varying irradiance, and can achieve a steady-state tracking accuracy of 99.8%. Besides, the proposed algorithm only needs to embed several lines of additional programs in the conventional hill climbing maximum power point tracking (MPPT) control program and does not require additional hardware components, which reduces the cost of PV power generation.