Most research on nanocrystalline alloys has been focused on planned doping of metals with other metallic elements, but nonmetallic impurities are also prevalent in the real world. In this work, we report on the combined effects of metallic dopants and nonmetallic impurities on grain boundary energy and strength using first-principles calculations, with a Σ5 (310) grain boundary in Cu chosen as a model system. We find a clear correlation between the grain boundary energy and the change in excess free volume of doped grain boundaries. A combination of a larger substitutional dopant and an interstitial impurity can fill the excess free volume more efficiently and further reduce the grain boundary energy. We also find that the strengthening effects of dopants and impurities are dominated by the electronic interactions between the host Cu atoms and the two types of dopant elements. For example, the significant competing effects of metal dopants such as Zr, Nb, and Mo with impurities on the grain boundary strength are uncovered from the density of states of the d electrons. As a whole, this work deepens the field's understanding of the interaction between metallic dopants and nonmetallic impurities on grain boundary properties, providing a guide for improving the thermal stability of materials while avoiding embrittling effects.