  We give a geometric derivation of Branson's Q-curvature in terms of the
ambient metric associated with conformal structures; it naturally follows from
the ambient metric construction of conformally invariant operators and can be
applied to a large class of invariant operators. This procedure can be also
applied to CR geometry and gives a CR analog of the Q-curvature; it then turns
out that the Q-curvature gives the coefficient of the logarithmic singularity
of the Szego kernel of 3-dimensional CR manifolds.
