Cooperation and betrayal are universal features of social interactions, and knowing who to trust is vital in human society. Previous studies have identified brain regions engaged by decision making during social encounters, but the mechanisms supporting modification of future behaviour by utilizing social experience are not well characterized. Using functional magnetic resonance imaging (fMRI), we show that cooperation and betrayal during social exchanges elicit specific patterns of neural activity associated with future behaviour. Unanticipated cooperation leads to greater behavioural adaptation than unexpected betrayal, and is signalled by specific neural responses in the striatum and midbrain. Neural responses to betrayal and willingness to trust novel partners both decrease as the number of individuals encountered during repeated social encounters increases. We propose that, as social groups increase in size, uncooperative or untrustworthy behaviour becomes progressively less surprising, with cooperation becoming increasingly important as a stimulus for social learning. Effects on reputation of non-trusting decisions may also act to drive pro-social behaviour. Our findings characterize the dynamic neural processes underlying social adaptation, and suggest that the brain is optimized to cooperate with trustworthy partners, rather than avoiding those who might betray us.