Second-party punishment (SPP) and third-party punishment (TPP) are two basic forms of costly punishment that play an essential role in maintaining social orders. Despite scientific breakthroughs in understanding that costly punishment is driven by an integration of the wrongdoers' intention and the outcome of their actions, so far, few studies have compared the neurocognitive processes associated with the intention-outcome integration between SPP and TPP. Here, we combined economic exchange games measuring SPP and TPP with functional magnetic resonance imaging (fMRI) to compare the neuropsychological architectures underlying the intention-outcome integration during one-shot interactions with anonymous partners across four types of norm violations (no norm, accidental, attempted, and intentional violations). Our behavioral findings showed that third-parties punished only attempted norm violations less frequently than second-parties. Our neuroimaging findings revealed higher activities in the right temporoparietal junction (TPJ) and dorsolateral prefrontal cortex (dlPFC) for attempted norm violations during TPP relative to SPP; more activities in these regions with less punishment frequency; and enhancement of functional connectivity of the right TPJ with the right dlPFC and dorsomedial PFC. Our findings demonstrated specific psychological and neural mechanisms of intention-outcome interactions between SPP and TPP -helping to unravel the complex neurocognitive processes of costly punishment.