The film reveals that Ponyo is not just a magical fish but the daughter of a sea goddess, effectively a demigod. Her use of magic to become human throws the world out of balance, pulling the moon closer to Earth. The twist is that there is no 'villain' to defeat; the conflict is the imbalance itself.
The climax involves a test: Sosuke must promise to love Ponyo in all her forms. If he fails, she will turn into sea foam (like the original Little Mermaid). He succeeds, and Gran Mamare allows Ponyo to stay human, but she must lose her magic permanently. The 'happy ending' comes with a sacrifice: Ponyo gives up her divine power and longevity to live a mortal life with Sosuke, restoring the balance of nature.