This paper proposes a linear quadratic regulator with integral action, ensuring fast dynamic response and resisting capability of voltage deviation from instantaneous reference grid voltage, to control the inverter voltage that can also be used in a microgrid. The proposed control strategy is based on a linear quadratic regulator, minimizing the cost function of the system, with integral action used to impede voltage degradation from a reference voltage for outside disturbances of the system, such as abrupt load change. The combined integral term assists to recover the voltage difference between grid and reference grid voltage. The validity of the proposed controller has been tested with linear and non-linear loads under various conditions. In both cases, the effectiveness of the controller has been proved. The result of the proposed controller is good to track the instantaneous reference grid voltage.