The history of the Philippines can be divided into four distinct phases: the pre-Spanish period (before 1521); the Spanish period (1521-1898); the American period (1898-1946); and the post-independence period (1946-present).
The first people in the Philippines, the Negritos, are believed to have come to the islands 30,000 years ago from Borneo and Sumatra, making their way across then-existing land bridges. Subsequently, Malays came from the south in successive waves, the earliest by land bridges and later in boats by sea. The Malays settled in scattered communities, named barangays after the large outrigger boats in which they arrived, and ruled by chieftains known as datus. Chinese merchants and traders arrived and settled in the ninth century, sometimes traveling on the ships of Arab traders, introducing Islam in the south and extending some influence even into Luzon. The Malays, however, remained the dominant group until the Spanish arrived in the 16th century.
Portuguese explorer Ferdinand Magellan reached the Philippines and claimed the archipelago for Spain in 1521, but stayed for only a few days. Christianity was established in the Philippines only after the arrival of the succeeding Spanish expeditionary forces (the first led by Legazpi in the 16th century) and the Spanish Jesuits, and in the 17th and 18th centuries by the conquistadores.
Until Mexico proclaimed independence from Spain in 1810 the islands were under the administrative control of Spanish North America, and there was significant migration between North America and the Philippines. This period was the era of conversion to Roman Catholicism. A Spanish colonial social system was developed with a local government centered in Manila and with considerable clerical influence. Spanish influence was strongest in Luzon and the central Philippines but less so in Mindanao, save for certain coastal cities.
The long period of Spanish rule was marked by numerous uprisings. Towards the latter half of the 19th century, European-educated Filipinos or ilustrados (such as the Chinese Filipino national hero Jose Rizal) began to criticize the excesses of Spanish rule and instilled a new sense of national identity. This movement gave inspiration to the final revolt against Spain that began in 1896 under the leadership of Emilio Aguinaldo (another Chinese Filipino) and continued until the Americans defeated the Spanish fleet in Manila Bay on May 1, 1898, during the Spanish-American War. Aguinaldo declared independence from Spain on June 12, 1898.