The golden city of Lanka was originally ruled by a demon called Sumali. After Lord Vishnu defeated Sumali in a fierce battle, the demons fled Lanka and retreated to the underworld. Kubera, the god of wealth, and the other demigods then took over the kingdom of Lanka. Kubera was the son of the powerful Sage Vishrava and his first wife, Idavida. Sumali and his daughter, the enchanting Kaikasi, hatched a plan to restore Lanka to the demons: Kaikasi would seduce Sage Vishrava, marry him, and bear a demon son who could vanquish Kubera.
Sage Vishrava and the demoness Kaikasi eventually had four demon children. The oldest was a boy with ten heads, twenty arms, and a big chest. He was named Dashagriva (meaning 'ten-headed') and later became known as Ravana. The second child was the gigantic Kumbhakarna, and the third was the timid Vibhishana. The youngest was a girl—the devious Shurpanakha.
To obtain boons from Lord Brahma, the demon brothers Ravana, Kumbhakarna, and Vibhishana undertook intense penance atop Mount Gokarna for several years. Frustrated by Brahma's silence, the ten-headed Ravana chopped his heads off one by one and offered them to the sacrificial fire. As he was about to cut off his tenth head, Brahma appeared before the brothers and asked each of them to make a wish.
"Let my mind always be set on the path to righteousness," wished Vibhishan. Brahma gladly granted him this boon.
Kumbhakarna wanted to ask for Indrasana (the throne of Indra), but at Indra's request, Goddess Saraswati bewitched his tongue so that he asked for Nidrasana (a bed for sleeping) instead. So Brahma decreed that he would sleep throughout the year. Ravana requested Brahma to undo Kumbhakarna's boon as it was actually a curse. Brahma relented and modified the boon: Kumbhakarna would sleep for six months, wake up for a day on which he would eat to his heart's content, and then sleep for another six months.
It was then Ravana's turn to make a wish. He first wished for immortality, but Brahma refused, saying that every creature that is born must die. Ravana then said, "I wish that no god, demigod, gandharva, or demon will ever be able to kill me." Brahma granted him this boon and also restored all of his heads. In his pride, Ravana had neglected to include humans in his wish, and that would be his undoing.
Emboldened by Brahma's boon, Ravana decided to challenge his older half-brother Kubera. He went to Lanka and demanded that Kubera return Lanka to the demons. Kubera acquiesced in order to avoid a bloody war between the demigods and the monsters. After leaving Lanka, he and the other demigods settled in Alakapuri near Mount Kailash, the abode of Lord Shiva and Goddess Parvati in the Himalayas.
Thus, Ravana became the king of Lanka and soon began his reign of terror over the three worlds.