Solute segregation to individual grain boundaries is used by design to produce strong and stable nanocrystalline metallic alloys. Grain-boundary segregation, however, is known to cause adverse embrittlement effects from a strain-localization failure mechanism that imposes significant material limitations for structural applications. Here, using atomistic simulations, it is discovered that heterogeneous Ni segregation in nanocrystalline Ni-mixed Ag alloys dramatically shuts down localized shear bands during plastic deformation, while simultaneously increasing the tensile strength. Nanocrystalline Cu-mixed Ag metals are predicted to exhibit standard homogeneous Cu segregation and a tensile strength that saturates above a solute concentration of 8 at.% due to glass-like shear localization induced by grain boundaries. By contrast, it is found that heterogeneous Ni segregation in nanocrystalline Ag-Ni alloys forms solute-rich clusters along interfaces leading to strain delocalization at high strain and continuous strengthening at high solute concentrations up to 15 at.%. This study reveals the importance of heterogeneous versus homogeneous segregation behaviors on strain localization and points to a fundamentally new strategy to design failure-resistant nanostructured materials through grain boundary segregation engineering.