In this paper we develop a model to analyze, in a dynamic framework, how countries join international environmental agreements (IEAs). In the model, where countries suffer from the same environmental damage as a result of the total global emissions, a non-signatory country decides its emissions by maximizing its own welfare, whereas a signatory country decides its emissions by maximizing the aggregate welfare of all signatory countries. Signatory countries are assumed to be able to punish the non-signatories at a cost. When countries decide on their pollution emissions they account for the evolution of the pollution over time. Moreover, we propose a mechanism to describe how countries reach a stable IEA. The model is able to capture situations with partial cooperation in an IEA stable over time. It also captures situations where all countries participate in a stable agreement, or situations where no stable agreement is feasible. When more than one possibility coexists, the long-term outcome of the game depends on the initial conditions (i.e. the size of the initial group of signatory countries and the pollution level).