Ravana was furious that Hanuman had come to Lanka as Rama's messenger. He ordered Vibhishana to set Hanuman's tail on fire and take him in a procession through the streets of Lanka.
Accordingly, Hanuman's tail was tied with a rope and set on fire. As Hanuman walked down the streets, people laughed at him.
Sita begged Agnideva not to hurt Hanuman. Agnideva cooled his flames and though Hanuman's tail was still ablaze it did not hurt him. Meanwhile, Hanuman decided to have some fun. Shrinking in size he quickly shook off the rope. Then leaping from building to building, he set them on fire. Soon the entire city of Lanka was burning.
Fearing that his prank might have hurt Sita, Hanuman rushed to see her but was relieved to see her safe.
Then bidding her farewell, he jumped into the sea and across to Rama.