The gypsy Esmeralda captures the hearts of many men, including those of Captain Phoebus and Pierre Gringoire, but especially Quasimodo and his guardian Archdeacon Claude Frollo. Frollo is torn between his obsessive lust for Esmeralda and the rules of the Notre Dame Cathedral. He orders Quasimodo to kidnap her, but the hunchback is captured by Phoebus and his guards, who save Esmeralda.
The following day, Quasimodo is sentenced to be flogged and turned on the pillory for one hour, followed by another hour's public exposure. He calls for water. Esmeralda, seeing his thirst, approaches the public stocks and offers him a drink of water. It saves him, and she captures his heart.
Later, Esmeralda is arrested and charged with the attempted murder of Phoebus, whom Frollo actually attempted to kill in jealousy after seeing him trying to seduce Esmeralda. She is sentenced to death by hanging. As she is being led to the gallows, Quasimodo swings down by the bell rope of Notre Dame and carries her off to the cathedral under the law of sanctuary, temporarily protecting her from arrest.
Frollo later informs Gringoire that the Court of Parlement has voted to remove Esmeralda's right to sanctuary so she can no longer seek shelter in the cathedral and will be taken away to be killed. Clopin, the leader of the Gypsies, hears the news from Gringoire and rallies the citizens of Paris to charge the cathedral and rescue Esmeralda.
When Quasimodo sees the Gypsies, he assumes they are there to hurt Esmeralda, so he drives them off. Likewise, he thinks the King's men want to rescue her, and tries to help them find her. She is rescued by Frollo and her phony husband Gringoire. But after yet another failed attempt to win her love, Frollo betrays Esmeralda by handing her to the troops and watches while she is being hanged.
When Frollo laughs during Esmeralda's hanging, Quasimodo pushes him from the heights of Notre Dame to his death. Quasimodo later goes to Montfaucon, a huge graveyard in Paris where the bodies of the condemned are dumped, where he stays with Esmeralda's dead body and dies of starvation. About eighteen months later, the tomb is opened, and the skeletons are found. As someone tries to separate them, they crumble to dust.

Question: Why does Quasimodo scare off the gypsies?
Answer: He thinks they are trying to hurt Esmeralda. 
Alternative answer: He thinks they are there to hurt Esmerelda.