Two and a half years later, Naruto returns from his training with Jiraiya. The Akatsuki starts kidnapping the hosts of the powerful Tailed Beasts. Team 7 (and other ninja) fight against them, and search for their teammate Sasuke. The Akatsuki succeeds in capturing and extracting seven of the Tailed Beasts, killing all the hosts exceptGaara (the host of the One-Tail) who is saved by Naruto and his comrades. Meanwhile, Sasuke betrays Orochimaru and faces Itachi to take revenge. After Itachi dies in battle, Sasuke learns from the Akatsuki founder Tobi that Itachi received an order from Konoha's superiors to destroy his clan to prevent a coup d'état. He accepted it on the condition that he would be allowed to leave Sasuke alive. Saddened by this revelation, Sasuke joins the Akatsuki to kill Konoha's superiors and destroy Konoha in revenge. As Konoha ninjas defeat several Akatsuki members, the Akatsuki figurehead leader, Nagato, kills Jiraiya and devastates Konoha, but Naruto defeats and redeems him, earning the village's respect and admiration.
With Nagato's eventual death, Tobi, disguised as Madara Uchiha (one of Konoha's founding fathers), announces that he wants to get all nine of the tailed beasts to perform an illusion powerful enough to control all humanity, to createworld peace. The leaders of the five ninja villages refuse to help him and instead join forces to confront Tobi and his allies. That decision results in afourth great ninja war between the combined armies of the Five Great Countries (known as the Allied Shinobi Forces) and Akatsuki's forces of zombie-like ninjas.Tsunade tries to keep Naruto in the village, unaware of the war, but Naruto finds out and escapes from the village with Killer Bee, the host of the Eight-Tails, and the two of them head for the battlefield.
During the conflict, it is revealed that Tobi is Obito Uchiha, a former teammate of Kakashi's who was thought to be dead. The real Madara saved Tobi's life, and they have since collaborated. As Sasuke learns the history of Konoha, including the circumstances that led to his clan's downfall, he decides to protect the village and rejoins Naruto and Sakura to thwart Madara's and Obito's plans. However, Madara's body ends up possessed by Kaguya Ōtsutsuki, an ancient princess who intends to subdue all humanity. A reformed Obito sacrifices himself to help Team 7 stop her. Once Kaguya is sealed, Madara dies as well. Sasuke takes advantage of the situation and takes control of all the Tailed Beasts, as he reveals his goal of ending the current village system. Naruto confronts Sasuke to dissuade him from his plan, and after they almost kill each other in a final battle, Sasuke admits defeat and reforms. After the war, Kakashi becomes the Sixth Hokage and pardons Sasuke for his crimes. Years later, Kakashi steps down while Naruto marries Hinata Hyuga and becomes the Seventh Hokage, raising the next generation.