The human brain responds more strongly to racial ingroup than outgroup individuals' pain. This racial ingroup bias varies across individuals and has been attributed to social experiences. What remains unknown is whether the racial ingroup bias in brain activity is associated with a genetic polymorphism. We investigated genetic associations of racial ingroup bias in the brain activity to racial ingroup and outgroup faces that received painful or non-painful stimulations by scanning A/A and G/G homozygous of the oxytocin receptor gene polymorphism (OXTR rs53576) using functional MRI. We found that G/G compared to A/A individuals showed stronger activity in the anterior cingulate and supplementary motor area (ACC/SMA) in response to racial ingroup members' pain, whereas A/A relative to G/G individuals exhibited greater activity in the nucleus accumbens (NAcc) in response to racial outgroup members' pain. Moreover, the racial ingroup bias in ACC/SMA activity positively predicted participants' racial ingroup bias in implicit attitudes and NAcc activity to racial outgroup individuals' pain negatively predicted participants' motivations to reduce racial outgroup members' pain. Our results suggest that the two variants of OXTR rs53576 are associated with racial ingroup bias in brain activities that are linked to implicit attitude and altruistic motivation, respectively.