Laser modes may coalesce into a mode-locked state that enables femtosecond pulse compression. The nature of the interaction and the interaction time play fundamental roles in the onset of this collective state, but the investigation of the transition dynamics is technically challenging because phases are not always experimentally accessible. This is even more difficult for random lasers, a kind of disordered laser in which energies in play are much smaller than in the ordered macroscopic case. Here we investigate experimentally and numerically the dynamics of the phase-locking transition in a random laser. We developed an experimental setup able to pump individual modes with different pulse durations and found that the mode-locked regime builds only for quasicontinuous pumping, resulting in an emission linewidth dependent on the pump duration. Numerical simulation confirms experimental data.