  We study the doubly charmed tetraquark state $T_{cc}^+$ by the HAL QCD method
applied to the $D^*D$ system in $(2+1)$ flavor lattice QCD at nearly physical
pion mass, $m_\pi= 146$ MeV. We obtain the attractive potential at all
distances in the $S$-wave of the isoscalar $D^* D$ system, whose long distance
behavior is well described by the two-pion exchange (TPE), and it generates a
virtual pole near $D^* D$ threshold with a pole position $E_{\rm pole} = -59
(^{+53}_{-99}) (^{+2}_{-67})$ keV and an inverse scattering length
$1/a_0=0.05(5)(^{+2}_{-2})$ fm$^{-1}$. The virtual pole turns into a loosely
bound state pole if the pion mass in the TPE potential is extrapolated to the
physical value, $m_\pi =135$ MeV. The potential at the physical pion mass is
shown to give a semi-quantitative description of the $D^0 D^0\pi^+$ mass
spectrum at the LHCb.
