Princess Luna, briefly appearing as Nightmare Moon or Night Mare Moon, is an Alicorn pony, the younger sister of Princess Celestia and the main antagonist of the first two episodes of My Little Pony Friendship is Magic as Nightmare Moon. Luna is restored back to her former self through the magic of the Elements of Harmony and returns to rule Equestria alongside her older sister.
The younger Alicorn princess, later named Princess Luna, in the first episode's prologue.
Princess Luna is introduced in the prologue of the first episode, depicted in a series of medieval-like drawings with a narration that says "Two regal sisters who ruled together and created harmony for all the land", and "The eldest used her unicorn powers to raise the sun at dawn. The younger brought out the moon to begin the night."
The narration continues by stating: their subjects, the ponies, played in the day but "shunned" the night and slept through it, which made the younger Alicorn grow bitter, eventually refusing to lower the moon to make way for the dawn. Her bitterness "transformed her into a wicked mare of darkness: Nightmare Moon." The elder sister reluctantly harnessed the power of the Elements of Harmony and "banished her permanently in the moon," taking responsibility for both sun and moon, maintaining harmony in Equestria.
The name incorporates several plays on words: "mare" as in a female horse, "night mare" as in a mare of the night, and "nightmare" as in frightening dream, derived entirely from the medieval demon which haunts a person's mind with the use of horrifying visions. In addition, when imprisoned in the moon, Luna appears as a dark area on the moon's surface; a similar shape in astronomy is called a lunar mare (Latin for "sea", pronounced "mah-rey").
Nightmare Moon, from the prologue.
Following the prologue, Twilight Sparkle reads of a prophecy that states that "on the longest day of the thousandth year the stars will aid in her [The Mare in the Moon's] escape, and she will bring about nighttime eternal", though Spike dismisses it as "an old ponies' tale". While composing a letter to Princess Celestia warning her of the danger, an image of Nightmare Moon is reflected in a giant hourglass that Twilight passes by. The day of Nightmare Moon's return is also the thousandth day of the Summer Sun Celebration, so Princess Celestia sends Twilight to oversee the celebration's preparations which are held in Ponyville, and encourages Twilight to "Stop reading those dusty old books" and make some friends. The events of the first and second episodes revolve around Twilight Sparkle and her new friends' attempt to defeat Nightmare Moon by finding and using the Elements of Harmony, while Nightmare Moon tries to stop them in various ways. At the end of the second episode, Twilight and her friends confront Nightmare Moon and transform her back into Princess Luna, and she emotionally accepts Princess Celestia's offer to rule by her side again.
The show's developer, Lauren Faust, explained in a comment on her deviantArt page that Luna could not have been "drawn" from Nightmare Moon for a thousand years, and that Princess Celestia "did what she could" to orchestrate breaking the spell that turned Luna into Nightmare Moon. Faust added that this explanation is "as far as [she] ever got with it", and that the explanation might unfold differently on the show.
During the 2013 Comic Con it shows a sneak peek at Season 4, showing Princess Luna talking to Twilight as if she was Celestia, saying that she would be the princess angrily, but an eclipse caused her to transform into Nightmare Moon once again laughing evilly, frightening Twilight.
Prior to ruling Equestria
Stained-glass art of Celestia and Luna defeating Discord.
Princess Luna doesn't make any further appearances in the series until Luna Eclipsed, which aired exactly one year after her previous appearance. However, more of her history is mentioned in The Return of Harmony Part 1. In the episode, Princess Celestia tells Twilight Sparkle and her friends that she and Luna discovered the Elements of Harmony and used them to turn Discord, the Spirit of Chaos and Disharmony, into stone. Discord's spell is later broken because, as Celestia explains, "Luna and [herself] are no longer connected to the elements." In The Crystal Empire - Part 1 it is mentioned that she and Celestia worked together to defeat King Sombra, turning him into a shadow and imprisoning him in the frozen north.
Despite most ponies not recognizing Nightmare Moon upon her return, the episode Luna Eclipsed shows the ponies celebrating an annual festival called Nightmare Night, where foals go door-to-door in costumes collecting candy, which they later offer to the effigy of Nightmare Moon. Zecora tells in verse of the legend of Nightmare Moon, which explains the customs of the holiday:
Every year we put on a disguise
To save ourselves from her searching eyes
But Nightmare Moon just wants only one thing
To gobble up ponies in one quick swing
Hungrily, she soars the skies
If she sees nopony, she passes by
So if she comes and all is clear
Equestria is safe for another year
Fill up her belly with a treat or two
So she won't return to come eat you
When Princess Luna returns after her thousand-year absence, she is still mistaken by Spike and others as Nightmare Moon, especially by Pinkie Pie who rouses up a gaggle of foals by shrieking at misconstrued acts of violence perpetrated by Princess Luna.
Although she originally intended to change the festival into a "bright" celebration, at the end of the episode Luna accepts Nightmare Night for what it is: a night of innocent scares, harmless pranks, and lots of candy.
Personality as Nightmare Moon
Much like the archetypal, over-the-top villains, Nightmare Moon is overly confident of herself and dramatically declares that the protagonist is a fool (foal) for thinking she can defeat her, and that "the night will last forever".
Bitterness grew inside her turning her as Nightmare Moon.
The narration at the beginning of Friendship is Magic, part 1 speaks of Nightmare Moon's bitterness which transformed her. When she first appears, she intimidates the ponies with her evil laugh and pointed questions. She snidely refers to the ponies as her "beloved subjects", but appears genuinely impressed when Twilight Sparkle recognizes her as Nightmare Moon.
Nightmare Moon making the cliff tumble down.
Nightmare Moon uses her magic to set obstacles in Twilight and her friends' path to the Elements of Harmony indirectly, making creatures unwittingly assist her. These include the manticore whose paw she embeds with a thorn so he'd attack the ponies, or the sea serpent whose mustache she cuts off so he'd make the river impassible. She further indirectly attacks the ponies by causing a cliff side to collapse underneath the ponies' hooves, and by making trees appear as monsters. As the Shadowbolts, she tries to persuade Rainbow Dash to abandon her friends so they won't be able to cross a fallen bridge and reach the Elements of Harmony.
Despite her indirect approach, when she is attacked by the royal guards, she quickly repels them with lightning, then turns into mist and floats away. She also confronts Twilight Sparkle directly when the two charge at each other, right before shattering the Elements of Harmony.