One of the detrimental effects of ultraviolet radiation on DNA is the formation of the (6-4) photoproduct, 6-4PP, between two adjacent pyrimidine rings. This lesion interferes with replication and transcription, and may result in mutation and cell death. In many organisms, a flavoenzyme called photolyase uses blue light energy to repair the 6-4PP (ref. 3). The molecular mechanism of the repair reaction is poorly understood. Here, we use ultrafast spectroscopy to show that the key step in the repair photocycle is acyclic proton transfer between the enzyme and the substrate. By femtosecond synchronization of the enzymatic dynamics with the repair function, we followed the function evolution and observed direct electron transfer from the excited flavin cofactor to the 6-4PP in 225 picoseconds, but surprisingly fast back electron transfer in 50 picoseconds without repair. We found that the catalytic proton transfer between a histidine residue in the active site and the 6-4PP, induced by the initial photoinduced electron transfer from the excited flavin cofactor to 6-4PP, occurs in 425 picoseconds and leads to 6-4PP repair in tens of nanoseconds. These key dynamics define the repair photocycle and explain the underlying molecular mechanism of the enzyme's modest efficiency.