Diffusion method has been developed to preferentially dope the grain boundaries of YBa 2 Cu 3 O y bicrystals and polycrystals. Ca and Fe have been used as dopants in this study. The distribution of the dopants is highly localized in the grain boundaries. The critical current density of a YBa 2 Cu 3 O y textured polycrystalline sample is significantly enhanced by doping Ca in grain boundaries; however, it is significantly decreased by doping Fe in grain boundaries. The Ca-doping effect has been explained by charge-carrier compensation in the grain boundaries, which reduces the grain boundary resistance and thus increases the grain boundary critical current. The Fe-doping effect has been explained by worsening the hole loss in grain boundary region, which increases the grain resistance and thus decreases the grain boundary critical current.