Explaining altruistic cooperation is one of the greatest challenges for evolutionary biology. One solution to this problem is if costly cooperative behaviours are directed towards relatives. This idea of kin selection has been hugely influential and applied widely from microorganisms to vertebrates. However, a problem arises if there is local competition for resources, because this leads to competition between relatives, reducing selection for cooperation. Here we use an experimental evolution approach to test the effect of the scale of competition, and how it interacts with relatedness. The cooperative trait that we examine is the production of siderophores, iron-scavenging agents, in the pathogenic bacterium Pseudomonas aeruginosa. As expected, our results show that higher levels of cooperative siderophore production evolve in the higher relatedness treatments. However, our results also show that more local competition selects for lower levels of siderophore production and that there is a significant interaction between relatedness and the scale of competition, with relatedness having less effect when the scale of competition is more local. More generally, the scale of competition is likely to be of particular importance for the evolution of cooperation in microorganisms, and also the virulence of pathogenic microorganisms, because cooperative traits such as siderophore production have an important role in determining virulence.