Neural synchronization in the gamma-band (25-80Hz) can enhance and route information flow during sensory and cognitive processing. However, it is not understood how synchronization between neural groups is robustly achieved and regulated despite of large variability in the precise oscillation frequency. A common belief is that continuous frequency matching over time is required for synchronization and that thus rhythms with different frequencies cannot establish preferred phase-relations. Here, by studying gamma rhythms in monkey visual area V1, we found that the temporal variation of the frequency difference was to the contrary essential for synchronization. Gamma rhythms synchronized by continuously varying their frequency difference in a phase-dependent manner. The synchronization level and the preferred phase-relation were determined by the amplitude and the mean of the frequency difference variations. Strikingly, stronger variation of the frequency difference led to stronger synchronization. These observations were reproduced by a biophysical model of gamma rhythms and were explained within the theory of weakly coupled oscillators. Using a single and general equation, we derived analytical predictions that precisely matched our V1 gamma data across different stimulus conditions. Our work reveals the principles of how gamma rhythms synchronize, where phase-dependent frequency variations play a central role. These frequency variations are characteristic for the intermittent synchronization regime, a non-stationary regime naturally occurring between the state of complete synchrony and asynchrony. This regime allows for synchronization between rhythms of variable frequencies, which is essential for achieving robust synchronization in the complex and noisy networks of the brain.