We consider the evolution of primordial magnetic fields generated during cosmological, electroweak or QCD, phase transitions. We assume that the magnetic field generation can be described as an injection of magnetic energy to cosmological plasma at a given scale determined by the moment of magnetic field generation. A high Reynolds number ensures strong coupling between magnetic field and fluid motions. The subsequent evolution of the magnetic field is governed by decaying hydromagnetic turbulence. Both our numerical simulations and a phenomenological description allow us to recover "universal" laws for the decay of magnetic energy and the growth of magnetic correlation length in the turbulent (low viscosity) regime. In particular, we show that during the radiation dominated epoch, energy and correlation length of non-helical magnetic fields scale as conformal time to the powers -1/2 and +1/2, respectively. For helical magnetic fields, energy and correlation length scale as conformal time to the powers -1/3 and +2/3, respectively. The universal decay law of the magnetic field implies that the strength of magnetic field generated during the QCD phase transition could reach $\sim 10^{-9}$\,G with the present day correlation length $\sim 50$ kpc. The fields generated at the electroweak phase transition could be as strong as $\sim 10^{-10}$ G with correlation lengths reaching $\sim 0.3$\,kpc. These values of the magnetic fields are consistent with the lower bounds of the extragalactic magnetic fields.