Just as he is about to jump, Melman discovers that he isn't dying after all and the "brown spot" is natural for giraffes.
Just as he changes his mind about jumping into the lava, the ledge cracks and Gloria rescues him at the last minute.
He finds her on a date with another hippo and tells her date everything he loves about Gloria and that he should treat her right, which makes Gloria realize that Melman loves her for who she is and that she might return his feelings.
The next day, when the watering hole dries up and King Julien decides to sacrifice an animal for the Sky Gods, Melman offers himself.
In the end, Melman becomes less neurotic because he has finally won Gloria's love.
Now in a happy relationship with Gloria, Melman is having the time of his life.
The rest of the film is about how Melman (who is especially uncomfortable in the wild) and his friends get used to being stuck on this island, and in the end, they seem to be a bit used to it.