When judging the morality of an action, individuals may exhibit a bias stemming from group favoritism. It leads to the expression of different moral evaluations of the same behaviors performed by different social groups. The current study used event-related potentials (ERPs) to investigate the influence of in-group favoritism (in-group vs. homogeneous out-group) and out-group favoritism (in-group vs. high-quality out-group) on moral judgments. Two experiments were conducted, showing a higher moral score of the in-group compared to the homogeneous out-group by participants. ERP data indicated that in-group stimulation triggered larger P2 amplitudes than homogeneous out-group. Additionally, a larger N400-like amplitude, localized to the right hemisphere, was observed during the evaluation of the homogeneous out-group. Significantly, when comparing the in-group to the high-quality out-group, there was no discernible difference in moral scores or ERP amplitudes. Overall, the results indicate that in-group favoritism can affect moral judgments, especially when assessing homogeneous out-groups, but it can be reduced by the characteristics of groups.