This paper presents a new D-StatCom control algorithm which enables separate control of positive-and negative-sequence currents and decoupled control of -and -axes current components. The algorithm is based on the developed mathematical model in the -coordinates for a D-StatCom operating under unbalanced conditions. The problem of dc-side voltage ripple and ac-side harmonics generation due to unbalanced voltages/currents is solved by using switching function modulation, enabling the use of a relatively small capacitor on the dc side. The control algorithm is also suitable for high-power applications using multipulse voltage-source converters. The algorithm is tested by means of detailed simulation using PSCAD, where the performance is validated in the case of severe network fault and in the case of unbalanced load compensation. The compensator voltages are generated by means of pulsewidth modulation.