We survey the statistical thermodynamics of systems, occurring in astrophysics, whose properties are dominated by gravitational forces. In the non-relativistic case, the lack of extensivity of these systems leads to a non-standard thermodynamics, with a two-phase region in which the microcanonical specific heat is negative. In the relativistic case, there arises the phenomenon of gravitational collapse, in which stars become black holes. We argue that, since these systems have no microstructure that can be observed from outside, the statistical mechanical concepts of microstates and entropy are inapplicable to them. Accordingly, we formulate the thermodynamics of processes, in which a black hole participates, in terms of observable quantities that govern changes in the Gibbs potential of the open system constituting the exterior region. By a simple argument, based only on general demands of quantum theory, relativity and statistical thermodynamics, we infer that the sum of the entropy of the exterior region and a universal constant times the area of the black hole does not decrease in any process. This is precisely the generalized second law, first proposed by Bekenstein on the basis of the hypothesis that a black hole has an entropy proportional to its surface area. By contrast, our derivation of this law does not involve any concept of black hole entropy, since it is based on the statistical thermodynamics of observable open systems.