The invention discloses the optimal consistency control method and system of a nonlinear multi-agent system. The method is characterized by establishing a reference behavior model according to the individual dynamic characteristic of a heterogeneous multi-agent system, and using a leader-follower control model to form a multi-agent system formed by reference behavior models; then, constructing a dynamic graph game global error dynamical model according to the network topology structure of multiple agents, defining a multi-agent local performance index function, and according to the global Nashequilibrium, acquiring a Bellman optimal equation; and then, under the condition of only using local agent information, using an execution-evaluation execution network framework mode based on value function approximation to carry out online iterative learning, and acquiring an optimal consistency protocol to achieve the consistency of each reference model behavior. Compared with the prior art, byusing the method and the system of the invention, under the condition of guaranteeing optimal control performance, the consistency problem of the complex multi-agent system can be high-efficiently solved, and an actual application value and high scalability are achieved.