  In a complete metric space equipped with a doubling measure supporting a
$p$-Poincar\'e inequality, we prove sharp growth and integrability results for
$p$-harmonic Green functions and their minimal $p$-weak upper gradients. We
show that these properties are determined by the growth of the underlying
measure near the singularity. Corresponding results are obtained also for more
general $p$-harmonic functions with poles, as well as for singular solutions of
elliptic differential equations in divergence form on weighted $\mathbf{R}^n$
and on manifolds.
  The proofs are based on a new general capacity estimate for annuli, which
implies precise pointwise estimates for $p$-harmonic Green functions. The
capacity estimate is valid under considerably milder assumptions than above. We
also use it, under these milder assumptions, to characterize singletons of zero
capacity and the $p$-parabolicity of the space. This generalizes and improves
earlier results that have been important especially in the context of
Riemannian manifolds.
