The $B\to \pi\pi$ hadronic matrix element
of the chromomagnetic dipole operator $O_{8g}$
(gluonic penguin) is calculated using the QCD
light-cone sum rule approach. The resulting sum rule for
$\langle \pi\pi |O_{8g}|B\rangle $ contains, in addition
to the $O(\alpha_s)$ part induced by hard gluon exchanges,
a contribution due to soft gluons. We find that in the
limit $m_b\to \infty$ the soft-gluon contribution
is suppressed as a second power of $1/m_b$ with respect
to the leading-order factorizable $B\to \pi\pi$ amplitude,
whereas the hard-gluon contribution has only an $\alpha_s$
suppression. Nevertheless, at finite $m_b$, soft
and hard effects of the gluonic penguin in $B\to \pi\pi$
are of the same order. Our result indicates that soft
contributions are indispensable for an accurate counting
of nonfactorizable effects in charmless $B$ decays.
On the phenomenological side we predict that the
impact of gluonic penguins on $\bar{B}^0_d\to \pi^+\pi^-$
is very small, but is noticeable for $\bar{B}^0_d\to \pi^0\pi^0$.