Long ago, Luna and Celestia were both the rulers of Equestria, a land inhabited by ponies. Every morning, Celestia would raise the sun, and every evening, Luna would raise the moon. Together, they kept the balance perfectly. One day, however, Luna grew jealous: the ponies would be awake to enjoy the day and love, admire, and appreciate Celestia's work, but would always sleep through her far more beautiful night. In anger, Luna refused to lower the moon, thus bringing eternal night. Celestia tried to reason with Luna, but the bitterness in her heart had transformed her into a corrupted form of herself: Nightmare Moon. To protect Equestria, Celestia used the Elements of Harmony to magically seal her sister inside the moon, creating the phenomenon known as "the Mare in the Moon" (a unicorn's face imprinted upon the surface of the moon). It is said that in a thousand years, on the longest day of that year, Nightmare Moon will make her return.
Nightmare Moon's return and redemption Edit
Upon reading an ancient legend, Twilight Sparkle realized Nightmare Moon is about to return, however her mentor, Princess Celestia, encouraged her to make friends instead of worrying about the supposed "old pony's tale". Unfortunately, Twilight turned out to be right and Nightmare Moon was released during the Summer Sun Celebration, replacing Celestia who was supposed to attend it. Twilight and her soon-to-be friends chased Nightmare Moon into the forbidden Everfree Forest. After conquering many obstacles left by Nightmare Moon in their path, they finally found the twisted mare herself along with the ancient Elements of Harmony, now reduced to inert stones. As Nightmare Moon whisked the Elements away, Twilight followed her into the portal and confronted her alone. She tried to use the Elements of Harmony like Celestia did, but for that she had to find the "spark" that would make a sixth Element appear. However, no matter how hard she tried, she couldn't make the spark, and Nightmare Moon destroyed the Elements.
Fortunately, when Twilight heard her new pony friends calling for her, she felt a different spark in her heart; making her realize that the real Elements are not just some stones: they exist in the hearts of her friends. That spark triggered the final element: Magic (also known, of course, as Friendship), and reanimated the shattered Elements, converting them into jewels for the six friends to bear. Using the Elements of Harmony, Twilight activated a spell that struck Nightmare Moon, exercising the darkness from her and transforming her back into Princess Luna.
Celestia arrived in the ruins where the battle took place, admitting that she knew of Nightmare Moon's return, but knew the only way to defeat her was for Twilight to understand the importance of friendship. Celestia walked over to a cowering Luna, who apologized in tears for her actions, and was granted forgiveness. Later at the celebration (held by Pinkie Pie), even the other ponies forgave Luna, gifting her with a flower necklace.