We compute and investigate four types of imprint of a stochastic background of primordial magnetic fields (PMFs) on the cosmic microwave background (CMB) anisotropies: the impact of PMFs on the CMB spectra; the effect on CMB polarization induced by Faraday rotation; the impact of PMFs on the ionization history; magnetically-induced non-Gaussianities; and the magnetically-induced breaking of statistical isotropy. Overall, Planck data constrain the amplitude of PMFs to less than a few nanogauss. In particular, individual limits coming from the analysis of the CMB angular power spectra, using the Planck likelihood, are $B_{1,mathrm{Mpc}}< 4.4$ nG (where $B_{1,mathrm{Mpc}}$ is the comoving field amplitude at a scale of 1 Mpc) at 95% confidence level, assuming zero helicity, and $B_{1,mathrm{Mpc}}< 5.6$ nG for a maximally helical field.For nearly scale-invariant PMFs we obtain $B_{1,mathrm{Mpc}}<2.0$ nG and $B_{1,mathrm{Mpc}}<0.9$ nG if the impact of PMFs on the ionization history of the Universe is included. From the analysis of magnetically-induced non-Gaussianity we obtain three different values, corresponding to three applied methods, all below 5 nG. The constraint from the magnetically-induced passive-tensor bispectrum is $B_{1,mathrm{Mpc}}< 2.8$ nG. A search for preferred directions in the magnetically-induced passive bispectrum yields $B_{1,mathrm{Mpc}}< 4.5$ nG, whereas the the compensated-scalar bispectrum gives $B_{1,mathrm{Mpc}}< 3$ nG. The analysis of the Faraday rotation of CMB polarization by PMFs uses the Planck power spectra in $EE$ and $BB$ at 70 GHz and gives $B_{1,mathrm{Mpc}}< 1380$ nG. In our final analysis, we consider the harmonic-space correlations produced by Alfven waves, finding no significant evidence for the presence of these waves. Together, these results comprise a comprehensive set of constraints on possible PMFs with Planck data.