Abstract The leader-following consensus problem of second-order heterogeneous nonlinear multi-agent systems (MASs) is studied in this paper. Based on the free-will arbitrary time (FWAT) theory, a piecewise distributed controller is developed to solve this problem within an arbitrary pre-specified convergence time. It should be noted that the pre-specified convergence time is independent of any system parameters and initial conditions. Furthermore, compared with the existing FWAT methods, consensus can still be maintained after the convergence time under the protocol designed in this work. Finally, numerical examples are given to illustrate the validity of the proposed method.