An optimal synchronous trajectory tracking controller was developed for multi-axis systems. The position synchronization error on each axis was defined as the position difference between this axis and the following axes. The following error of each axis, the synchronization error, and its derivative were considered in the cost function. A Riccati equation was deduced from the Hamilton-Pontryagin equation. The optimal control law was set up from the Riccati equation solution. Simulations of a two-axis system show that the synchronization error can be significantly reduced and the synchronization performance can be adjusted based on the parameters in the cost function.