One of the predictions of game theory is that cooperative behaviours are vulnerable to exploitation by selfish individuals, but this result seemingly contradicts the survival of cooperation observed in nature. In this review, we will introduce game theoretical concepts that lead to this conclusion and show how the spatial competition dynamics between microorganisms can be used to model the survival and maintenance of cooperation. In particular, we focus on how Escherichia coli bacteria with a growth advantage in stationary phase (GASP) phenotype maintain a proliferative phenotype when faced with overcrowding to gain a fitness advantage over wild-type populations. We review recent experimental approaches studying the growth dynamics of competing GASP and wild-type strains of E. coli inside interconnected microfabricated habitats and use a game theoretical approach to analyse the observed inter-species interactions. We describe how the use of evolutionary game theory and the ideal free distribution accurately models the spatial distribution of cooperative and selfish individuals in spatially heterogeneous environments. Using bacteria as a model system of cooperative and selfish behaviours may lead to a better understanding of the competition dynamics of other organisms-including tumour-host interactions during cancer development and metastasis.