Costly punishment of social norm transgressors by third-parties has been considered as a decisive stage in the evolution of human cooperation. An important facet of social relationship knowledge concerns the strength of the social ties between individuals, as measured by social distance. Yet, it is unclear how the enforcement of social norms is influenced by the social distance between a third-party and a norm violator at the behavioral and the brain system levels. Here, we investigated how social distance between punishers and norm-violators influences third-party punishment. Participants as third-party punished norm violators more severely as social distance between them increased. Using model-based fMRI, we disentangled key computations contributing to third-party punishment: inequity aversion, social distance between participant and norm violator and integration of the cost to punish with these signals. Inequity aversion increased activity in the anterior cingulate cortex and bilateral insula, and processing social distance engaged a bilateral fronto-parietal cortex brain network. These two brain signals and the cost to punish were integrated in a subjective value signal of sanctions that modulated activity in the ventromedial prefrontal cortex. Together, our results reveal the neurocomputational underpinnings of third-party punishment and how social distance modulates enforcement of social norms in humans.