Lord Shen, the scion of a peacock clan that rules Gongmen City in ancient China, seeks to weaponize gunpowder, which had recently been invented to create fireworks. After discovering from the court's goat soothsayer that "a warrior of black-and-white" will defeat him if he does not change his ways, Shen leads an army of wolves to exterminate the panda population to avert the prophecy. Shen's parents are horrified at this atrocity and exile their son, who swears revenge.
Thirty years later, Po is living his dream as the Dragon Warrior, protecting the Valley of Peace alongside his friends and fellow kung fumasters, 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 ended up in the Valley of Peace.
Shifu receives word that Shen has returned to Gongmen City and killed Thundering Rhino, the leader of the kung fu council protecting the City, and is plotting to conquer China with his newly developed weapon, a cannon. Shifu sends Po and the Furious Five 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 boss and give chase, only to be arrested in front of Shen's tower.
Upon being brought before Shen in his tower, Po and the Five free themselves and destroy Shen's weapon. However, Po is again distracted by a flashback upon seeing the same symbol as before on Shen's plumage, realizing Shen was there the last night Po saw his parents. This allows Shen to escape and destroy the tower with an arsenal of cannons. After Po and the Five escape, Tigress tells Po to stay behind for his own safety. Despite this, Po breaks into the factory to question Shen about his past, 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, where he is presumed dead.
Po survives and is rescued by the 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. A battle ensues between Shen's armada, sailing in the heart of Gongmen City, and Po and the Five, joined by Shifu, who has persuaded Ox and Croc to help. Po modifies the movements used during his inner peace training to redirect Shen's cannonballs against his own armada, destroying it. Po then urges Shen to let go of his own past, but Shen attacks Po until Shen slashes the ropes holding up his last cannon, which falls on top of him, crushing him to death while the ship explodes. 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 birth father is revealed to have survived Shen's attack and is shown to be living in a far-off, hidden village inhabited by surviving pandas, and senses that his son is still alive.