  We compute the beta functions for the three gauge couplings and the Yukawa
matrices of a general two-Higgs-doublet model in the modified minimal
subtraction scheme to three loops. The calculations are performed using Lorenz
gauge in the unbroken phase. We discuss in detail the occurence of poles in
anomalous dimensions and propose practical prescriptions to avoid them. We
provide explicit results for the often used $\mathbb{Z}_2$-symmetric versions
of the two-Higgs-doublet model of type I, II, X and Y. Furthermore, we provide
the first independent cross-check of the three-loop Yukawa coupling beta
functions of the Standard Model.
