In this paper, the leader-following consensus of second-order nonlinear multiagent systems (SONMASs) with external disturbances is studied. Firstly, based on terminal sliding model control method, a distributed control protocol is proposed over undirected networks, which can not only suppress the external disturbances, but also make the SONMASs achieve consensus in finite time. Secondly, to make the settling time independent of the initial values of systems, we improve the protocol and ensure that the SONMASs can reach the sliding surface and achieve consensus in fixed time if the control parameters satisfy some conditions. Moreover, for general directed networks, we design a new fixed-time control protocol and prove that both the sliding mode surface and consensus for SONMASs can be reached in fixed time. Finally, several numerical simulations are given to show the effectiveness of the proposed protocols.