High penetration levels of distributed photovoltaic (PV) generation on an electrical distribution circuit may degrade power quality due to voltage sags and swells caused by rapidly varying PV generation during cloud transients coupled with the slow response of existing utility compensation and regulation equipment. Fast-reacting, VAR-capable PV inverters may provide the necessary reactive power injection or consumption to maintain voltage regulation under difficult transient conditions. As side benefit, the control of reactive power injection at each PV inverter provides a new tool for distribution utilities to minimize the thermal losses in circuit. We suggest a local control scheme that dispatches reactive power from each PV inverter based on local instantaneous measurements of the real and reactive components of the consumed power and the real power generated by the PVs. Using one adjustable parameter per circuit, we balance the requirements on power quality and desire to minimize thermal losses. The performance of the proposed control scheme is evaluated via numerical simulations of realistic rural lines in several generation/consumption scenarios. Simultaneous improvement of both the power quality and the magnitude of losses is observed for all the scenarios, even when the renewable generation in excess of the circuit own load.