Precise predictions are provided for the production of a $mathrm{Z}$-boson and a $mathrm{b}$-jet in hadron-hadron collisions within the framework of perturbative QCD, at $mathcal{O}(alpha_s^3)$. To obtain these predictions we perform the first calculation of a hadronic scattering process involving the direct production of a flavoured-jet at next-to-next-to-leading order accuracy in massless QCD, and extend techniques to also account for the impact of finite heavy-quark mass effects. The predictions are compared to CMS data obtained in $mathrm{pp}$ collisions at a centre-of-mass energy of $8~mathrm{TeV}$, which are the most precise data from Run I of the LHC for this process, where a good description of the data is achieved. To allow this comparison we have performed an unfolding of the data, which overcomes the long-standing issue that the experimental and theoretical definitions of jet flavour are incompatible.