In the Ramayana, we know that Ravana was the King of the golden city of Lanka. How did he get this city? I know very little other than that it was offered by Shiva.
The story of Lanka is described in detail in the Uttara Kanda of the Ramayana. (The links in my answer link to different excerpts from the Uttara Kanda.) There were three Rakshasa (demon) brothers named Sumali, Mali, and Malyavan who obtained a boon of invincibility from Brahma and then told the divine architect Vishwakarma, "Erect a mansion for us resembling the mansion itself of Maheshwara [i.e. Shiva]." So on the island mountain Suvela, Vishwakarma "construct[ed] a city of Lanka there, having an area of thirty yojanas, and measuring an hundred (sic) in length; surrounded by a golden wall and furnished with golden gateways ... having a strong wall and a moat, abounding in hundreds of golden edifices". But then Vishnu defeated the three brothers, killing Mali and driving Sumali, Malyavan, and their Rakshasa comrades away to Patalaloka (the netherworld). Since Lanka was abandoned by the Rakshasas, when Kubera son of the sage Vishravas was made the god of wealth, he moved into Lanka at his father's suggestion.
Later on, the demon Sumali I mentioned earlier got his daughter Kaikeshi married to Kubera's father Vishravas, and they had many children including Ravana. Ravana got a boon of near-invincibility from Brahma, so at his grandfather Sumali's urging he attempted to retake Lanka for the Rakshasas. When Kubera heard that his half-brother Ravana wanted to move into Lanka, he was more than happy to have him, saying this:
My father had given [Lanka] to me, when it had been emptied of Rakshasas; and ... I have inhabited this place, furnished with charity, honor, and other virtues ... [A]s this city and kingdom are mine, so they are thine, O mighty-armed one. Do thou enjoy this kingdom without a foe. May my kingdom and wealth never undergo division when thou art present.
But Ravana wasn't willing to share the kingdom; he wanted it exclusively for him and his fellow Rakshasas, so Kubera at his father's suggestion abandoned Lanka and went to the Himalayas. That is how Lanka came to be under Ravana's possession. (Contrary to popular belief Ravana did not fight Kubera over Lanka; like I said he got Lanka without a fight. The battle between them happened later, when Ravana was attacking everyone under the sun in his attempt to take over the three worlds. It was during that battle that Ravana defeated Kubera and took the Pushpaka Vimana.)