Elements of Harmony

The Elements of Harmony are the most powerful magic known to ponykind. They are made up of the six key elements: Honesty, Kindness, Laughter, Generosity, Loyalty, and Magic.

Legend
According to legend, Princess Celestia used the Elements of Harmony to imprison her sister, Nightmare Moon into the moon due to her evil actions. Only five of the six elements were known, with the sixth element being a complete mystery. The last known location for the five elements was in the ancient castle of the royal pony sisters located in the Everfree Forest. They were represented as five stone orbs when Twilight and her friends found them. According to the Reference Guide, when the five are present a spark will cause the sixth element to be revealed.

The Elements of Harmony are actually Spirits which resided in the stone orbs. After Nightmare Moon destroyed the orbs, a spark within Twilight Sparkle ignited upon hearing her new friends arrive to her aid. Her acknowledgment of her friends awakened the spirits which fused with Rarity, Applejack, Fluttershy, Rainbow Dash, and Pinkie Pie. The shards of the stones became necklaces (as well as a tiara for Twilight) as they each represent the Elements.

Cutie Mark Connection
The six bearers of the elements all got their cutie marks at roughly the same time, despite the fact that only two of them (Fluttershy and Rainbow Dash) knew each other at the time, and they would not all gather as a group for many years. The catalyst for this event was the Sonic Rainboom created by Rainbow Dash during a race, which affected each pony's life in different ways. It is implied that this highly unlikely occurance indicated that the six of them were destined to unite as friends even before they had met each other. It is possible that the destined wielders of the Elements of Harmony are magically drawn together when needed.

Bearers of the Elements
Applejack's Element is Honesty. As Applejack tries to save Twilight from hanging over the edge of a long drop, she said to let go of her, much to Twilight's surprise. Applejack said that to trust her and she will be OK. Twilight trusts her and lets go and is caught by Rainbow Dash and Fluttershy. Her spirit was symbolized by her gold necklace with a citrine shaped like her cutie mark.
 * Applejack

Fluttershy's Element is Kindness. When the group encounters an angry manticore, they decide to fight to get past it. But Fluttershy intervenes and approaches it, discovering that a thorn stuck in its paw is the cause of its rage. She removes it and calms the beast, letting the ponies pass. Her spirit was symbolized by her gold necklace with a pink opal shaped like her cutie mark.
 * Fluttershy

Pinkie Pie's Element is Laughter. After wandering into a darkened area of the forest, the group are frightened by trees carved with scary faces. However, Pinkie just laughed and made funny faces, causing the faces to vanish. She explains that they can conquer their fears simply by laughing at them. Her spirit was symbolized by her gold necklace with a blue topaz shaped like her cutie mark.
 * Pinkie Pie

Rarity's Element is Generosity. After encountering a flamboyant sea serpent who is upset about its mustache being ruined, Rarity, who is angered by this "crime against fabulousity" sympathies with him and cuts off her own tail so that his mustache can be restored. Her spirit was symbolized by her gold necklace with an amethyst shaped like her cutie mark.
 * Rarity

Rainbow Dash's Element is Loyalty. After the ponies reached the old castle, Rainbow Dash decides to repair the rope bridge for them to get across. She is confronted by a group of dark ponies who call themselves The Shadowbolts and ask Dash to join them as their captain, telling her she has to choose them over her friends. Dash declines their offer and ties the bridge, letting the others cross. Her spirit was symbolized by her gold necklace with a ruby shaped like her cutie mark.
 * Rainbow Dash

Twilight Sparkle's Element is Magic. After she realized that she has friends, a spark within her ignited upon hearing her new friends arrive to her aid. This not only causes the five spirits to reveal themselves but also to reveal the sixth and final element. Her spirit was symbolized by her gold tiara with a magenta tourmaline shaped like her cutie mark.
 * Twilight Sparkle

Trivia

 * The Elements of Harmony are the only magical items existing in the series.