Madoka Kaname, a girl living in the provincial city of Mitakihara, is a somewhat shy, ordinary middle school student.
However, she learns of the existence of girls who become "magical girls" and fight witches, and becomes involved in their battles.
Saddened by the sight of magical girls being wounded and falling, she wishes to Kyubey to "eliminate all witches before they are born."
Thus, Madoka transforms into a supernatural concept called the "Law of Cycles," and through its power, the world is remade in a way that witches do not exist.
Homura Akemi, bearing Madoka's final will in her heart, vows to continue fighting the "magical beasts" that have come to roam in place of witches.
She continues to fight, dreaming of the day she will be guided by the Law of Cycles. Homura was living her daily life as a magical girl.
It was a life of fighting Nightmares, but also a fun life with her friends.
However, she began to feel something was wrong with her everyday life, and finally came to a crucial realization. It was the existence of "Kaname Madoka," who shouldn't exist in this world.
This was a false space, a fabricated world created by Homura herself, who was gradually becoming a witch, in order to regain her everyday life with Madoka.
The magical girls unite to thwart Kyubey's scheme, who knew their secret and was trying to use it.
But this meant acknowledging that Homura had become a witch, and that Madoka was an existence detached from the world as the Law of Cycles.
Therefore, in the final moment, in order to not lose Madoka, Homura becomes a "demon" who demeans Madoka, who is almost godlike, and reshapes the world herself.