Five years after the Viking village of Berk and the dragons made peace, they now live together in harmony. Hiccup goes on adventures with his dragon, Toothless, as they discover and map unexplored lands. Now 20 years old, he is being pressed by his father, Stoick the Vast, to succeed him as chieftain, although Hiccup remains unsure if he is ready for this responsibility.
While investigating a burnt forest, Hiccup and Astrid discover the remains of a fort encased in ice and meet a group of dragon trappers led by Eret, who blames them for his fort's destruction and attempts to capture their dragons for an insane conqueror named Drago Bludvist. The two dragon riders escape and return to Berk to warn Stoick about the dragon army that Drago is amassing. Stoick orders the villagers to fortify the island and prepare for battle. Hiccup, however, refuses to believe that war is inevitable. After Stoick interrupts Hiccup's plan to get Eret to take him to Drago, Stoick explains that he once met Drago at a gathering of chiefs, where Drago, mocked after offering the chiefs his service in return for their servitude, murdered them all using armored dragons, with Stoick as the only survivor. Undeterred, Hiccup flies off with Toothless in search of Drago to try to reason with him.
They run into a dragon rider named Valka, who is revealed to be Hiccup's long-lost mother. She explains that she, like her son, could not bring herself to kill dragons. After being carried off during a dragon raid, she spent twenty years rescuing dragons from Drago's traps and bringing them to an island nest created out of ice by a gigantic Alpha dragon called a "Bewilderbeast", which is able to control smaller dragons. Stoick tracks Hiccup to the nest, where he discovers that his wife is still alive. Meanwhile, Astrid and the other riders kidnap Eret to find Drago, but Drago captures them and learns of Berk's dragons.
Drago and his armada lay siege to the nest, where he reveals that he has his own Bewilderbeast to challenge the Alpha. A battle ensues between the two colossal dragons, which ends with Drago's Bewilderbeast killing its opponent and becoming the new Alpha. Drago's Bewilderbeast then seizes control of all the adult dragons, who hypnotically obey. Hiccup tries to persuade Drago to end the violence, but Drago orders him killed. Toothless, under the Bewilderbeast's influence, approaches Hiccup and launches a blast, but Stoick pushes Hiccup out of the way and is hit instead, killing him. The Bewilderbeast momentarily relinquishes control of Toothless, but Hiccup drives him away in a fit of despair. Drago maroons Hiccup and the others on the island and rides Toothless, again under the control of the Bewilderbeast, to lead his army to conquer Berk. Stoick is given a Viking funeral and Hiccup, now having lost both his father and dragon, is unsure what to do. Valka encourages him by telling him that he alone can unite humans and dragons, and inspired by her words and his father's, Hiccup decides to return to Berk to stop Drago.
The dragon riders fly baby dragons back to Berk, as they are immune to the Bewilderbeast's control. They find that Drago has already attacked the village and taken control of its dragons. Hiccup confronts Drago and a brainwashed Toothless while the other riders work to distract the Bewilderbeast. Hiccup succeeds in freeing Toothless from the Bewilderbeast's control, much to Drago's surprise. Hiccup and Toothless briefly separate Drago from the Bewilderbeast and confront Drago on the ground, but the Bewilderbeast attacks them, encasing them in ice. However, Toothless blasts away the ice, revealing that both he and Hiccup are unharmed. He then challenges the Bewilderbeast, shooting it in the face repeatedly, which breaks its control over the other dragons, who now side with Toothless as the new Alpha dragon. All the dragons repeatedly fire at the Bewilderbeast until Toothless fires a final massive blast, breaking its left tusk. Defeated, the Bewilderbeast retreats under the sea with Drago on its back. The Vikings and dragons celebrate their victory and Hiccup is made chieftain of Berk.
Afterwards, Berk undergoes repairs while feeling secure knowing that its dragons can defend it.
Output: How do Toothless and Hiccup escape from the ice?