AbstractWe construct an algorithm for solving a constrained optimal control problem for a first‐order evolutionary system governed by a positive self‐adjoint operator. The problem consists in identifying distributed control that minimizes a given cost functional, which comprises a cost of the control and a trajectory regulation term, while steering the final state close to a given target. The approach explores the dual problem and it generalizes the Hilbert Uniqueness Method (HUM). The practical implementation of the algorithm is based on a spectral decomposition of the operator determining the dynamics of the system. Once this decomposition is available – which can be done offline and saved for future use – the optimal control problem is solved almost instantaneously. It is practically reduced to a scalar nonlinear equation for the optimal Lagrange multiplier. The efficiency of the algorithm is demonstrated through numerical examples corresponding to different types of control operators and penalization terms.