While they walk in the forest, the group comes across an avalanche that knocks all the ponies down a cliff except for Fluttershy and Rainbow Dash, the pegusi which pulls the rest of ponies except for Twilight Sparkle which Applejack saves but she couldn't pull her up so she lets go and Twilight falls but Fluttershy and Rainbow Dash catch her.
After wandering into a darkened area of the forest, the group are frightened by trees carved with scary faces. ( This was Nightmare Moon’s doing.) However, Pinkie just laughed and made funny faces, causing the faices to vanish. Singing a song, Pinkie explained to them that if you laugh your fears will vanish. After laughing for a while, they move on.
The ponies enter the castle ruins and come to stand in front of several stone orbs perched on a pedestal, which Twilight assumes are the Elements of Harmony. Dash and Fluttershy place them at Twilight's feet, and Pinkie notices there are only five of them. Twilight explains that when the five are present, a spark would cause the sixth to be revealed. The rest of the ponies leave as Twilight tries to use her magic on the orbs, but the purple mist appears and envelops them in a whirlwind. Twilight jumps in and disappears along with the purple mist. The other ponies see glowing lights in another part of the ruins and head to it. Twilight and Nightmare Moon re-appear at opposite ends of a large hall, with the stone orbs around Nightmare Moon. Twilight stamps her hoof and charges at Nightmare Moon, leading her to do the same.
Right before they collide, Twilight disappears, then reappears next to the orbs. She tries to use her magic to create a spark, but Nightmare Moon turns into mist and rematerializes in front of her, and blasts her away from the orbs. For a moment the orbs sparkle and frighten Nightmare Moon, but they soon stop, allowing her to shatter them by stamping on the ground. Pleased with this, Nightmare Moon declares victory, swirling her purple mist around herself.
Then, Twilight hears her friends calling with reassuring words, and something sparks inside her. She gives Nightmare Moon a speech on the Elements of Harmony, declaring the spirits of the Elements of Harmony are "right here", as the other five ponies arrive behind her. The stone fragments glow and float around each pony as Twilight explains which element each of them represents based on their actions during their journey. Nightmare Moon protests, saying they don't have the sixth element, but Twilight tells her a different kind of spark revealed the sixth element, the spark that she felt when she realized the five other ponies are her friends.
When Twilight concludes the speech, the fragments turn into jewels, and the six ponies glow and float in the air as a rainbow emerges from them and covers Nightmare Moon. Twilight opens her eyes, which floods the room with bright white light. Once the light fades, the ponies discover that Rarity's tail is restored, and that they all have jewelry that matches their cutie marks.
Back in Ponyville, Pinkie throws a party to celebrate the reunion of the two Princesses - but Twilight looks sad. When asked why, Twilight tells Celestia she's sad of leaving her new friends and returning home, so Celestia issues her with a new mission: study the magic of friendship in Ponyville, and report her findings. Twilight is happy about being able to stay with her friends and promises to study harder than ever before.