  The two gravitational form factors of the pion, $A^{\pi}(t)$ and
$D^{\pi}(t)$, are computed as functions of the momentum transfer squared $t$ in
the kinematic region $0\leq -t< 2~\text{GeV}^2$ on a lattice QCD ensemble with
quark masses corresponding to a close-to-physical pion mass $m_{\pi}\approx
170~\text{MeV}$ and $N_f=2+1$ quark flavors. The flavor decomposition of these
form factors into gluon, up/down light-quark, and strange-quark contributions
is presented in the $\overline{\text{MS}}$ scheme at energy scale
$\mu=2~\text{GeV}$, with renormalization factors computed nonperturbatively via
the RI-MOM scheme. Using monopole and $z$-expansion fits to the gravitational
form factors, we obtain estimates for the pion momentum fraction and $D$-term
that are consistent with the momentum fraction sum rule and the next-to-leading
order chiral perturbation theory prediction for $D^{\pi}(0)$.
