The purpose of this paper is to determine the exact distribution of the final size of an epidemic for a wide class of models of susceptible–infective–removed type. First, a nonstationary version of the classical Reed–Frost model is constructed that allows us to incorporate, in particular, random levels of resistance to infection in the susceptibles. Then, a randomized version of this nonstationary model is considered in order to take into account random levels of infectiousness in the infectives. It is shown that, in both cases, the distribution of the final number of infected individuals can be obtained in terms of Abel–Gontcharoff polynomials. The new methodology followed also provides a unified approach to a number of recent works in the literature.