An opening prologue tells that, years before the events of the first film, Lord Shen, the son of a peacock clan that rules Gongmen City in ancient China, seeks to harness fireworks as a weapon. After discovering from the court's goat Soothsayer that "a warrior of black-and-white" will defeat him, Shen leads an army to exterminate the panda population to avert the prophecy. Shen's parents are horrified at this atrocity and exile their son, who swears revenge.
In the present day, Po is living his dream as the Dragon Warrior, protecting the Valley of Peace alongside his friends and fellow kung fu masters, the Furious Five. His teacher Shifu tells him, however, that he has yet to achieve inner peace. While defending a village from wolf bandits who have been stealing refined metal for Shen, Po is distracted by a symbol on the wolf leader's armor, which causes Po to have a flashback of his mother and allows the wolves to escape. Po asks his goose father, Mr. Ping, about his origins. Ping reveals that he found Po as an infant in a radish crate and adopted him, but Po remains unsatisfied, wondering how and why he wound up in the Valley of Peace, to begin with.
Shifu receives word that Shen has killed Thundering Rhino, the leader of the kung fu council protecting Gongmen City, and is plotting to destroy kung fu tradition and conquer China with his newly developed weapon, a cannon. Po and the Furious Five set out to Gongmen City to stop Shen and destroy his weapon. They find the city occupied by Shen's forces, with the two surviving council members Storming Ox and Croc imprisoned. The six heroes ask the council members for help to liberate the city, but the two cite their helplessness against Shen's weapon and refuse. Po and the Five are discovered by the wolf leader and give chase, only to be captured in front of Shen's tower.
Upon being brought before Shen in his tower, Po and the Five free themselves and destroy Shen's cannon. However, Po is again distracted by a flashback upon seeing the same symbol as before on Shen's plumage, allowing Shen to escape and destroy the tower with an arsenal of cannons. After Po and the Five escape, Tigress confronts Po over his distraction, who reluctantly explains that he remembers Shen's presence on the night he was separated from his parents, and wants answers about his past from Shen. Though empathetic, Tigress tells Po to stay behind for his own safety. Despite this, Po breaks into the factory to question Shen, inadvertently foiling the Five's plan to destroy the factory. Shen claims that Po's parents abandoned him, and then blasts Po out of the factory into a river with a cannon.
Po survives and is rescued by the same Soothsayer, who takes him to the ruins of the nearby village where Po was born. Guided by the Soothsayer to embrace his past, Po remembers that when he was an infant, his parents had sacrificed themselves to save him from Shen's army, his mother hiding him in a radish crate and luring Shen's forces away from him. Po attains inner peace, realizing that he has lived a happy and fulfilling life despite this early tragedy.
Po returns to Gongmen City to save the captive Five and prevent Shen's conquest of China. During the ensuing battle (in which Ox and Croc participate after being persuaded by Shifu, who also helps), Po modifies the movements used during his inner peace training to redirect Shen's cannon fire against his own armada, destroying it. Po then urges Shen to let go of his own past, but Shen attacks Po until he slashes the ropes holding up his last cannon, which falls and crushes Shen to death. Victorious, Po returns to the Valley of Peace and reunites with Mr. Ping, lovingly declaring the goose to be his father. At the same time, Po's biological father is shown to be living in a far-off, hidden village inhabited by surviving pandas, and senses that his son is still alive.