  Let $\M$ be a smooth connected manifold endowed with a smooth measure $\mu$
and a smooth locally subelliptic diffusion operator $L$ satisfying $L1=0$, and
which is symmetric with respect to $\mu$. Associated with $L$ one has
\textit{le carr\'e du champ} $\Gamma$ and a canonical distance $d$, with
respect to which we suppose that $(M,d)$ be complete. We assume that $\M$ is
also equipped with another first-order differential bilinear form $\Gamma^Z$
and we assume that $\Gamma$ and $\Gamma^Z$ satisfy the Hypothesis below. With
these forms we introduce in \eqref{cdi} below a generalization of the
curvature-dimension inequality from Riemannian geometry, see Definition
\ref{D:cdi}. In our main results we prove that, using solely \eqref{cdi}, one
can develop a theory which parallels the celebrated works of Yau, and Li-Yau on
complete manifolds with Ricci bounded from below. We also obtain an analogue of
the Bonnet-Myers theorem. In Section \ref{S:appendix} we construct large
classes of sub-Riemannian manifolds with transverse symmetries which satisfy
the generalized curvature-dimension inequality \eqref{cdi}. Such classes
include all Sasakian manifolds whose horizontal Webster-Tanaka-Ricci curvature
is bounded from below, all Carnot groups with step two, and wide subclasses of
principal bundles over Riemannian manifolds whose Ricci curvature is bounded
from below.
