Competition enhances learning under certain circumstances. However, little is known about how the neural mechanisms involved in a competition during the episodic encoding are modulated by the social distance of personal relationships with opponents. To investigate this issue, using functional magnetic resonance imaging (fMRI), we scanned healthy young adults during a competition with their familiar friends and unfamiliar others in the episodic encoding. Three major findings emerged from this study. First, activations in the right temporo-parietal junction (rTPJ) were significantly greater in the competition with familiar friends than with unfamiliar others, and the activations in this region were significantly correlated with the subjective ratings of motivation. Second, striatum and amygdala activations increased by the competition with familiar friends were significantly correlated with the increased ratings of pleasantness, which reflected emotionally positive feelings in victory for the competition with familiar opponents. Third, the functional connectivity between the rTPJ and reward-related regions, including the striatum and substantia nigra, was higher in the competition with familiar friends than with unfamiliar others. Taken together with our behavioral findings, in which memories encoded by competing with familiar friends were remembered more accurately than those with unfamiliar others, the interacting mechanisms between the rTPJ that is involved in social motivation and the reward-related regions that are involved in social reward could contribute to the enhancement of memories encoded in the competition with familiar others.