Grain boundary hardening and precipitation hardening are important mechanisms for enhancing the strength of metals. Here, we show that these two effects can be amplified simultaneously in nanocrystalline compositionally complex alloys (CCAs), leading to near-theoretical strength and large deformability. We develop a model nanograined (TiZrNbHf)98Ni2 alloy via thermodynamic design. The Ni solutes, which has a large negative mixing enthalpy and different electronegativity to Ti, Zr, Nb and Hf, not only produce Ni-enriched local chemical inhomogeneities in the nanograins, but also segregate to grain boundaries. The resultant alloy achieves a 2.5 GPa yield strength, together with work hardening capability and large homogeneous deformability to 65% compressive strain. The local chemical inhomogeneities impede dislocation propagation and encourage dislocation multiplication to promote strain hardening. Meanwhile, Ni segregates to grain boundaries and enhances cohesion, suppressing the grain growth and grain boundary cracking found while deforming the reference TiZrNbHf alloy. Our alloy design strategy thus opens an avenue, via solute decoration at grain boundaries combined with local chemical inhomogeneities inside the grains, towards ultrahigh strength and large plasticity in nanostructured alloys.