This paper presents a discrete sliding-mode control scheme with feedforward compensation for the closed-loop regulation of the pulse-width modulated (PWM) inverter used in an uninterruptible power supply (UPS). The proposed feedforward controller can effectively improve the tracking performance of the PWM inverter. In designing the sliding-mode controller, we have taken load disturbance into consideration to enhance the robustness of the PWM inverter. Moreover, the upper bound of the load disturbance under which the sliding condition can be maintained has also been derived. The sliding curve of the sliding-mode controller is designed such that the behavior of the controlled PWM inverter is optimal subject to the selected cost function. Due to the coordinate transformation proposed in this paper, only the output voltage needs to be measured as feedback for the purpose of closed-loop regulation. Simulation and experimental results are given to show the effectiveness of the proposed control scheme.