Cooperation and altruistic behavior are enhanced in spatially structured populations as compared with mean-field scenarios [Nowak and May, 1992]. In most studies of evolutionary game theory with spatial structure, however, the size of the population is assumed to be constant. Here I study a model where the population may vary in response to environmental pressure p. I discuss two non-trivial effects. First, as increasing p dilutes the population, cooperation becomes dominant and prevents extinction for any non-zero efficiency of altruistic acts. Second, in a large region of the parameter space, the increase of cooperators overcompensates the decrease of defectors with growing p. Thus the overall population size rises in response to increasing environmental pressure. I obtain the phase diagram displaying these effects by stochastic simulations and confirm it by solving the equations of pair approximation.