Early polities in what is now the Philippines were small entities known as barangays, although some larger states were established following the arrival of Hinduism and Islam through regional trade networks. The arrival of Spanish settlers began a period of Spanish expansion which led to the creation of the Captaincy General of the Philippines, governed out of Manila. While technically part of New Spain, the Philippines functioned mostly autonomously. The reliance on native leaders to help govern led to the creation of an elite class known as the principalia. Spanish control was never firmly established over much of its claimed territory, with some inland and Islamic regions remaining effectively independent.