This paper proposes an intelligent attack defense and optimal control scheme for heterogeneous multi-agent systems (MASs) affected by false data injection (FDI) attacks. An attack detector is devised to detect the FDI attacks, and an isolation mechanism is developed to remove the attacked communication links. Since the inherently distributed spatial deployment of agents in MASs and limited communication ranges or topological constraints, some followers cannot communicate with a leader directly within the leader-following framework, a distributed observer is developed to reconstruct the leader’s information. On the basis of the reconstructed leader’s information, a data-driven iteration learning algorithm is devised to adaptively learn an optimal controller. Different from the existing methods, the superiority of the presented method is that it does not require the intelligent data-storage and the restrictive persistence of excitation condition, which saves the storage resources. Simulation is conducted to exemplify the advantage of the proposed approach.