The article considers a technique for constructing an optimal guidance procedure for an aerospace aircraft. The technique is based on the adaptation of the Pontryagin maximum principle for the considered class of problems. At the same time the guidance accuracy is ensured by solving a boundary value problem, which is periodically performed during the flight. The developed procedure for predicting the final parameters of the optimal flight according to a simplified motion model is presented, which also makes it possible to determine the value of the actual miss. A detailed mathematical description of the proposed technique is given. The feasibility of the proposed technique is ensured by minimizing the amount of computational operations. The guidance algorithm efficiency is illustrated by a numerical example with a flight simulation procedure taking into account all significant factors. The paper also provides examples of solving boundary value problems and the results of modeling the optimal guidance.