Enforcing geometric consistency of an acquired cone-beam computed tomography scan has been shown to be a promising approach for online geometry calibration and the compensation of rigid patient motion. The approach estimates the motion parameters by solving an optimization problem, where the cost function is the accumulated consistency based on Grangeat’s theorem. In all previous work, this is performed with zero-order optimization methods like the Nelder-Mead algorithm or grid search. We present a derivation of motion gradients enabling the usage of more efficient first-order optimization algorithms for the estimation of rigid patient motion or geometry misalignment. We first present a general formulation of the gradients, and explicitly compute the gradient for the longitudinal patient axis. To verify our results, we compare the presented analytic gradient with a finite difference. In a second experiment we compare the computational demand of the presented gradient with the finite differences. The analytic gradient clearly outperforms the finite differences with a speed up of ~35 %.