Due to increasing complexity in the power system, voltage sag is becoming one of the most significant power quality problems. Voltage sag is a short reduction voltage from nominal voltage, occurs in a short time. If the voltage sags exceed two to three cycles, then manufacturing systems making use of sensitive electronic equipments are likely to be affected leading to major problems. It ultimately leads to wastage of resources (both material and human) as well as financial losses. This is possible only by ensuring that uninterrupted flow of power is maintained at proper voltage levels. This project tends look at the solving the sag problems by using custom power devices such as Distribution Static compensator (D-STATCOM).Proposed scheme follows a new algorithm to generate reference voltage for a distribution static compensator (DSTATCOM) operating in voltage-control mode. The proposed scheme ensures that unity power factor (UPF) is achieved at the load terminal during nominal operation, which is not possible in the traditional method. Also, the compensator injects lower currents therefore, reduces losses in the feeder and voltage-source inverter. Further, a saving in the rating of DSTATCOM is achieved which increases its capacity to mitigate voltage sag. Nearly UPF is maintained, while regulating voltage at the load terminal, during load change. The state-space model of DSTATCOM is incorporated with the deadbeat predictive controller for fast load voltage regulation during voltage disturbances. With these features, this scheme allows DSTATCOM to tackle power-quality issues by providing power factor correction, harmonic elimination, load balancing, and voltage regulation based on the load requirement.