Defining computable analytical measures of the effects of selection in populations with demographic and environmental stochasticity is a long-standing problem. We derive an analytical measure which takes in account all consequences of the discrete nature of deme size. Expressions of this measure are detailed for infinite island models of population structure. As an illustration we consider the evolution of dispersal in populations made of small demes with environmental and demographic stochasticity. We confirm some results obtained from the analysis of models based on deterministic approximations. In particular, when there is an Allee effect, we show that evolution of the dispersal rate may lead the metapopulation to extinction. Thus, selection on the dispersal rate could restrict the distribution of species subject to Allee effects. This selection-driven extinction is prevented by kin selection when the environmental extinction rate is small.