This paper presents the application of a controller based on state space design for a shunt active filter with energy storage (SAFES) within a local power supply network in the presence of distributed generation. The aim is to guarantee voltage regulation and harmonic cancellation at the load site caused by a load step change or harmonic distortion. To achieve this objective, the SAFES is controlled to inject the appropriate current to the line. The reference fundamental current for the SAFES is calculated such that in the presence of voltage sags, it works in conjunction with local distributed generation, (which usually has slow dynamic response) to control the voltage at the point of common connection (PCC). The multivariable controller employs a full state observer to provide the SAFES reference voltage. This paper provides a theoretical analysis of the controller behaviour in presence of plant variations. Simulation results show that the proposed method makes it possible to regulate the grid voltage at its nominal value and can also provide harmonic injection if required