Displacement measurement is a fundamental functionality in modern science and technology. Although there has been remarkable progress in the precision of such measurements with various laser ranging methods(1-8), they are incapable of capturing fast and complex mechanical displacements. Here, we have established a displacement measurement method using time-of-flight detection(9) with femtosecond optical pulses and frequency-locked electrical waveforms. This method uniquely combines ultrafast measurement speed, sub-nanometre precision and non-ambiguity range of more than several millimetres. The achieved performance features unprecedented detection speed and precision. Starting from 24 nm precision for 4 ns acquisition time, the precision can reach 180 pm for 5 ms acquisition time. Using this method, we show real-time detection of single-event, fast and high-dynamic-range mechanical displacements. This capability can lead to the realization of new measurement and analysis platforms for studying broadband, transient and nonlinear mechanical dynamics in real time, which will be useful for directly probing optomechanics(10), the onset of cracks(11), dynamic deformations(12), nonlinear vibrations(13), ultrasonic phenomena(14) and cell-generated forces(15). Using a femtosecond mode-locked laser and a frequency-locked electric signal, a displacement measurement method that offers a >MHz measurement speed, sub-nanometre precision and a measurement range of more than several millimetres is achieved, facilitating the study of broadband, transient and nonlinear mechanical dynamics in real time.