This paper presents a control technique for enhancing the stable operation of distributed generation (DG) units during islanding and grid-connected modes. The compensation of instantaneous variations in the reference current components of DG units in ac-side, and dc-link voltage variations in dc-side of interfaced converters, are considered properly in the control loop of DG units, which is the main contribution and novelty of this control technique over other control techniques. By using the proposed control technique, DG units can provide the continuous injection of active power from DG sources to the local loads and/or utility grid. Moreover, by setting appropriate reference current components in the control loop of DG units, reactive power and harmonic current components of loads can be supplied with a fast dynamic response. The performance of the developed control is assessed through simulation results during dynamic and steady-state operating conditions.