We discuss different mechanisms of generation of stochastic magnetic fields in cosmology. The main contenders are magnetic fields generated during inflation or during a first order phase transition. We then study the evolution of the stochastic magnetic fields in the cosmic plasma via MHD turbulence. Finally we discuss whether the magnetic fields can be observed in the present Universe. We find that turbulent evolution leads to a very specific relation between the correlation scale and amplitude of the magnetic fields in the present Universe if they have evolved from early times via MHD turbulence.