The pre-compensation of contouring error can improve the machining quality effectively, but the pre-compensation values are not optimal by the existing methods. To obtain a better pre-compensation value of the contouring error for five-axis machine tools, this paper proposes a data-driven iterative pre-compensation method. In detail, a data-driven prediction model of tracking error is proposed first to avoid the negative impact of modeling error on the pre-compensation value. The output of the prediction model consists of two parts: a linear part and a nonlinear part. The linear part is obtained by the identified model of the drive system, while the nonlinear part, which is caused by the uncertainty of the drive system, is the output of a trained neural network. With the predicted tracking error, the contouring error can be further predicted through forward kinematic. Then, the pre-compensation value is calculated by predicting and accumulating the contouring error iteratively, which is close to being optimal. Through the iterative operation, the potential contour error is suppressed effectively. The convergence of the proposed iterative process is proved theoretically. Finally, the reference position command of each axis is modified before machining by using the calculated optimal value. The experiments were conducted on a self-constructed five-axis machine tool. The experimental results consistently indicate that, by the proposed pre-compensation method, the contouring error is predicted accurately and reduced significantly.