The mathematical model of five-axis NC machine tools was established based on the transformation matrix. A new decoupling and linkage-compensation method for five-axis NC machine tools is proposed. The error caused by linear axes and rotary axes was compensated by using the linkage-compensation approach. In the real-time error compensation process, the rotary axes error was compensated firstly, and then the linear error caused by linear axes and rotary axes was compensated. The new decoupling method can effectively compensate machining errors for five-axis NC machine tools, which was verified by simulation and actual machining.