  We present a comprehensive analysis of the muon magnetic moment $a_\mu$ in
the flavour-aligned two-Higgs doublet model (2HDM) and parameter constraints
relevant for $a_\mu$. We employ a recent full two-loop computation of $a_\mu$
and take into account experimental constraints from Higgs and flavour physics
on the parameter space. Large $a_\mu$ is possible for light pseudoscalar Higgs
A with large Yukawa couplings to leptons, and it can be further increased by
large A coupling to top quarks. We investigate in detail the maximum possible
Yukawa couplings to leptons and quarks of a light A, finding values of around
50...100 (leptons) and O(0.5) (quarks). As a result we find that an overall
maximum of $a_\mu$ in the 2HDM of more than $45\times10^{-10}$ is possible in a
very small parameter region around M_A=20 GeV. The parameter regions in which
the currently observed deviation can be explained are characterized.
