The islands were ruled by successive kingdoms and indigenous empires before Portuguese settlers took it . Then , it went to the British East India Company . For centuries , the islands came under the control of successive indigenous empires before being ceded to the Portuguese and subsequently to the British East India Company .