We study the amplification of magnetic fields during the formation of primordial halos. The turbulence generated by gravitational infall motions during the formation of the first stars and galaxies can amplify magnetic fields very efficiently and on short timescales up to dynamically significant values. Using the Kazantsev theory, which describes the so-called small-scale dynamo-a magnetohydrodynamical process converting kinetic energy from turbulence into magnetic energy-we can then calculate the growth rate of the small-scale magnetic field. Our calculations are based on a detailed chemical network and we include non-ideal magnetohydrodynamical effects such as ambipolar diffusion and Ohmic dissipation. We follow the evolution of the magnetic field up to larger scales until saturation occurs on the Jeans scale. Assuming a weak magnetic seed field generated by the Biermann battery process, both Burgers and Kolmogorov turbulence lead to saturation within a rather small density range. Such fields are likely to become relevant after the formation of a protostellar disk and, thus, could influence the formation of the first stars and galaxies in the universe.