I think it was explained fairly clearly, but I guess a lot of people still find it confusing. I'll try to write an explanation myself and hopefully it will help you with understanding the story ^_^
As we all remember, at the end of the anime the Madoka law took place, where every magical girl would disappear before she becomes a witch, right? And the only person who knows this and remembers Madoka is Homura.
And Homura told QB about the past "world order", so to speak, where the girls would turn into witches and how Madoka changed all that. Her wish was for her to erase every witch with her own hands! Since QB could not confirm the existence of Madoka, they sealed Homura in an enviroment, where if her soul gem were to "rot" away, Madoka can't come in to purify it and take her away. So, naturally, the "old world order" would still take place and Homura will begin to turn into a witch, but the barrier created around her by QB somehow stops that, that's why she still can turn into a magical girl, yet has some witch abilities like creating a barrier.
So we have a borderline witch Homura, which created a barrier and labyrinth inside it, since as we remember in the show, the souls are inside the soul gem and the bodies become only shells that carry the soul gem around. Kinda like a soul gem being a pilot and a human body being a mecha
That's why when Homura got on the bus to get away from the soul gem, she didn't "turn off" like how Sayaka did when Madoka threw her gem on top of a car - Homura is constantly inside the gem, so she can't get away from it.
After realizing this and finding out she is a witch, her despair grows up to the point where she "breaks" to the point where she is not between a witch and a puella magi, she is now a witch in her entirety... but she grows inside the soul gem, not the real world.
Even in her witch form, her only goal is to save Madoka from QB, that's why she "captures" Madoka and creates a new world order.
TL; DR so far:
- QB seals an almost "dead" Homura inside a barrier
- Madoka can't come in to purify her and take her away
- Homura turns into a witch inside her soul gem
- To protect Madoka, Homura rewrites the universe again
The ending of the movie is basically Homura overthrowing Madoka in order to keep protecting her. She came to realize that even as a God, Madoka can still become a victim to QB's search for power.