The recent advances in high-power semiconductor technology have made control of electric power in transmission lines more reliable and faster. Nowadays, FACTS devices are used in power systems in controlling and compensation of transmission lines. These devices are based on semiconductor and electronic technology that have advantages over traditional controlling devices. UPFC is one of the most recent kinds of FACTS that are made up from two PWM converters, which share a single dc link. UPFC is a controlling device in power systems that can control three important parameters, namely, impedance, voltage and phase angle, simultaneously. In addition, it is widely used in harmonic compensation in power systems. In this paper, based on instantaneous power theory, a control strategy has been developed to improve UPFC operation for simultaneous harmonic compensation and power flow control. The two main features of the proposed control model are improvement of dynamic stability and reduction of interaction between real and reactive powers. The simulation results clearly show satisfactory performance of the proposed model.