Abstract In spatial linear fitting, it is not possible to directly adopt the method of total least squares algorithm and mixed total least squares. This paper proposes a space linear fitting algorithm based on the PEIV model of the total least squares method. The standard equation of space straight line is transformed and the equation is rewritten as the overall least squares EIV model. Then, according to the characteristics of the coefficient matrix, the model is transformed into a more reasonable PEIV model, linearly similar to the least squares indirect adjustment form, and the iterative method is used to solve the fitting parameters. The adjustment process ensures that the correction number of the elements of the coefficient matrix is the same, and the correction number of the constant element is zero, which is in accordance with the actual theory. Finally, the feasibility and superiority of the method are verified by an example.