The problem of optimal reorientation of the spacecraft orbit is considered in quaternion formulation. Control (vector of the acceleration of the jet thrust) is limited in magnitude. It is required to determine the optimal orientation of the vector of the acceleration in space to solve the problem. It is necessary to minimize the energy consumption of the process of reorientation of the spacecraft orbit. We used quaternion differential equation of the orientation of the spacecraft orbit to describe the motion of the center of mass of the spacecraft. The problem was solved using the maximum principle of L. S. Pontryagin. We simplified the differential equations of the problem using known partial solution of the equation for the variable conjugated to true anomaly. The problem of optimal reorientation of the spacecraft orbit was reduced to a boundary value problem with a moving right end of the trajectory described by a system of nonlinear differential equations of fifteenth order. For the numerical solution of the obtained boundary value problem the transition to dimensionless variables was carried out. At the same time a characteristic dimensionless parameter of the problem appeared in the phase and conjugate equations. We constructed an original numerical algorithm for finding unknown initial values of conjugate variables. The algorithm is a combination of Runge-Kutta 4th order method and two methods for solving boundary value problems: modified Newton method and gradient descent method. The using of these two methods for solving boundary value problems has improved the accuracy of the solution of the investigated boundary value problem of optimal control. Examples of numerical solution of the problem are given for the cases when the difference (in angular measure) between initial and final orientations of the spacecraft orbit is equals to a few (or tens of) degrees. Graphs of changes component of the quaternion of the spacecraft orbit orientation; variables characterizing the shape and dimensions of the spacecraft orbit; optimal control are plotted. The analysis of the obtained solutions is given. The features and regularities of the process of optimal reorientation of the spacecraft orbit are established. We found that when the difference between initial and final spacecraft orbits is small there is a one point of extremum for the eccentricity of the spacecraft orbit and for modulo of the vector of orbital velocity moment of the spacecraft. And there are a few points of local extremum for these functions when the difference between initial and final spacecraft orbits is large.