The circadian rhythm of the cyanobacterium Synechococcus elongatus is controlled by three proteins, KaiA, KaiB, and KaiC. In a test tube, these proteins form complexes of various stoichiometry and the average phosphorylation level of KaiC exhibits robust circadian oscillations in the presence of ATP. Using mathematical modeling, we were able to reproduce quantitatively the experimentally observed phosphorylation dynamics of the KaiABC clockwork in vitro. We thereby identified a highly non-linear feedback loop through KaiA inactivation as the key synchronization mechanism of KaiC phosphorylation. By using the novel method of native mass spectrometry, we confirm the theoretically predicted complex formation dynamics and show that inactivation of KaiA is a consequence of sequestration by KaiC hexamers and KaiBC complexes. To test further the predictive power of the mathematical model, we reproduced the observed phase synchronization dynamics on entrainment by temperature cycles. Our model gives strong evidence that the underlying entrainment mechanism arises from a temperature-dependent change in the abundance of KaiAC and KaiBC complexes.