Judge Frollo follows Phoebus and Quasimodo when they venture to the Court of Miracles to warn Esmeralda of Frollo's plans to exterminate the gypsies. Phoebus and the gypsies are locked up, Quasimodo is chained up in the Notre Dame belltower, and Esmeralda is to be burned at the stake (because she refuses to be Frollo's lover).
Quasimodo breaks free and spirits Esmeralda into the tower, and a fight breaks out between the freed gypsies and Frollo's men, aided by Quasimodo keeping the latter from entering the cathedral. But Frollo makes it inside and tries to kill the refugees - he almost does but falls from the tower at the crucial moment. Quasimodo almost falls to his death too but is saved by Phoebus.
Phoebus and Esmeralda are reunited (to presumably be wed), and they encourage Quasimodo to finally walk amongst the townspeople undisguised - and from the example of a little girl who is not afraid of his ugliness, they accept him as the hero he is and carry him off in celebration.