From the Forgotten Realms Campaign Setting book:
Clerics of Chauntea, Selune, and Shar tell of the following legend.
Lord Ao created the universe that now holds the world of Toril. After this creation came a period of timeless nothingness, a misty realm of shadows that existed before light and darkness were separate things. Eventually this shadowy essence coalesced to form beautiful twin goddesses, polar opposites of each other, one dark and one light. He twin goddesses created the bodies of the heavens, giving life to Chauntea, the embodiment of the world Toril. Toril was lit by the cool radiance of the goddess Selune and darkened by the welcoming embrace of the goddess Shar, but no heat existed in this place.
Chauntea begged for warmth so that she might nurture life and living creatures upon her form, and the twin goddesses disagreed over whether this should be done. The two fought, and from their divine conflict the deities of war, disease, murder, death, and other fell forces were created.
Selune reached beyond the universe to a plane of fire, using pure flame to ignite one of the heavenly bodies so that Chauntea would be warmed. Shar became enraged and began to snuff out all light and warmth in the universe. Desperate and greatly weakened, Selune tore the divine essence of magic from her body and hurled it at her sister, tearing through Shar’s form and pulling with it similar energy from the dark twin. This energy formed Mystryl, the goddess of magic. Composed of light and dark magic but favoring her first mother, Mystryl balanced the battle and established an uneasy truce between the two sisters.
Shar, who remained powerful, nursed a bitter loneliness in the darkness and plotted her revenge. Selune waxed and waned with the light, but drew strength from her allied daughters and sons, and even interloper deities from other planes. Their battle continues to this day.
The birth of the being known as Mystryl did more than just balance the war between the sisters of light and darkness. Her very existence changed the reality of the universe by creating the Weave, the conduit that allows creatures to use magic. Suddenly, rather than magic being restricted to just the deities, any creature with the talent or training could draw upon the power of magic through the Weave. When sentient creatures appeared on Toril, some of them learned to use the Weave while shamans and clerics drew their magic directly from the deities. Acknowledgement of her gift led to worship, and Mystryl drew power from that, becoming one of the more powerful deities.