Cooperation underlies diverse phenomena including the origins of multicellular life, human behaviour in economic markets and the mechanisms by which pathogenic bacteria cause disease. Experiments with microorganisms have advanced our understanding of how, when and why cooperation evolves, but the extent to which microbial cooperation can recapitulate aspects of animal behaviour is debated. For instance, understanding the evolution of behavioural response rules (how should one individual respond to another's decision to cooperate or defect?) is a key part of social evolution theory, but the possible existence of such rules in social microbes has not been explored. In one specific context (biparental care in animals), cooperation is maintained if individuals respond to a partner's defection by increasing their own investment into cooperation, but not so much that this fully compensates for the defector's lack of investment. This is termed ‘partial compensation’. Here, I show that partial compensation for the presence of noncooperating ‘cheats’ is also observed in a microbial social behaviour: the cooperative production of iron-scavenging siderophores by the bacterium Pseudomonas aeruginosa. A period of evolution in the presence of cheats maintains this response, whereas evolution in the absence of cheats leads to a loss of compensatory behaviour. These results demonstrate (i) the remarkable flexibility of bacterial social behaviour, (ii) the potential generality of partial compensation as a social response rule and (iii) the need for mathematical models to explore the evolution of response rules in multi-player social interactions.