In this paper, the leader–follower consensus problem is investigated for multi‐agent systems subject to external disturbances generated by heterogeneous nonlinear exosystems. First, the disturbance observers are developed for each follower to effectively estimate the nonlinear disturbances. Then, based on the presented observers, the distributed state and output feedback consensus protocols are proposed to guarantee that the consensus tracking errors converge to zero asymptotically, and meanwhile to reject the nonlinear disturbances. Particularly, the output feedback protocol can be designed and implemented without any global information about the whole network, which means it is fully distributed. Finally, two numerical examples are given to illustrate the effectiveness of the results.