The history of the Philippines is believed to have begun with the arrival of the first humans using rafts or primitive boats, at least 67,000 years ago as the 2007 discovery of Callao Man showed. The first recorded visit from the West is the arrival of Ferdinand Magellan, who sighted the island of Samar Island on March 16, 1521 and landed on Homonhon Island (now part of Guiuan, Eastern Samar province) the next day. Homonhon Island is southeast of Samar island. 
Before Magellan arrived, Negrito tribes roamed the isles, but they were later supplanted by Austronesians. These groups then stratified into: hunter-gatherer tribes, warrior societies, petty plutocracies and maritime-oriented harbor principalities which eventually grew into kingdoms, rajahnates, principalities, confederations and sultanates. States such as the Indianized Rajahnate of Butuan and Cebu, the dynasty of Tondo, the august kingdoms of Maysapan and Maynila, the Confederation of Madyaas, the sinified Country of Mai, as well as the Muslim Sultanates of Sulu and Maguindanao. These small maritime states flourished from as early as the 1st Millenium. These kingdoms traded with what are now now called China, India, Japan, Thailand, Vietnam, and Indonesia. The remainder of the settlements were independent Barangays allied with one of the larger states. The “balangay” or “barangay” represented an independent community in the Archipelago ruled by a “Datu”. There were, however, instances where a Datu of a certain barangay was aided by a council of elders in running the affairs of the baranggay similar to privy councils of European monarchs. In that patriarchal society, the Datu and his family constituted the highest authority in the barangay and were therefore considered the equivalent of European monarchs. His rule was absolute. He dispensed justice and declared war against other barangays. Therefore, at the apex of pre-Spanish nobility in the Philippine Archipelago, was the Datu – the term commonly use by the Tagalogs. In Mindanao, ‘Sultan’ and ‘Rajah’ were used accordingly for the highest chief of their respective communities.
Spanish colonization and settlement began with the arrival of Miguel López de Legazpi's expedition on February 13, 1565 who established the first permanent settlement of San Miguel on the island of Cebu. The expedition continued northward reaching the bay of Manila on the island of Luzon on June 24, 1571, where they established a new town and thus began an era of Spanish colonization that lasted for more than three centuries.
Spanish rule achieved the political unification of almost the whole archipelago, that previously had been composed by independent kingdoms and communities, pushing back south the advancing Islamic forces and creating the first draft of the nation that was to be known as the Philippines. Spain also introduced Christianity, the code of law, the oldest Universities and the first public education system in Asia, the western European version of printing, the Gregorian calendar and invested heavily on all kinds of modern infrastructures, such as train networks and modern bridges.
The Spanish East Indies were ruled as part of the Viceroyalty of New Spain and administered from Mexico City from 1565 to 1821, and administered directly from Madrid, Spain from 1821 until the end of the Spanish–American War in 1898, except for a brief period of British rule from 1762 to 1764. During the Spanish period, numerous towns were founded, infrastructures built, new crops and livestock introduced. The Chinese, British, Portuguese, Dutch, Japanese, and indigenous traders, complained that the Spanish reduced trade by attempting to enforce a Spanish monopoly. Spanish missionaries attempted to convert the population to Christianity and were eventually generally successful in the northern and central lowlands. They founded schools, a university, and some hospitals, principally in Manila and the largest Spanish fort settlements. Universal education was made free for all Filipino subjects in 1863 and remained so until the end of the Spanish colonial era. This measure was at the vanguard of contemporary Asian countries, and led to an important class of educated natives, like Jose Rizal. Ironically, it was during the initial years of American occupation in the early 20th century, that Spanish literature and press flourished.
The Philippine Revolution against Spain began in August 1896, but it was largely unsuccessful until it received support from the United States, culminating two years later with a proclamation of independence and the establishment of the First Philippine Republic. However, the Treaty of Paris, at the end of the Spanish–American War, transferred control of the Philippines to the United States. This agreement was not recognized by the insurgent First Philippine Republic Government which, on June 2, 1899, proclaimed a Declaration of War against the United States. The Philippine–American War which ensued resulted in massive casualties. Philippine president Emilio Aguinaldo was captured in 1901 and the U.S. government declared the conflict officially over in 1902. The Filipino leaders, for the most part, accepted that the Americans had won, but hostilities continued and only began to decline in 1913, leaving a total number of casualties on the Filipino side of more than one million dead, many of them civilians.
The U.S. had established a military government in the Philippines on August 14, 1898, following the capture of Manila. Civil government was inaugurated on July 1, 1901. An elected Philippine Assembly was convened in 1907 as the lower house of a bicameral legislature. Commonwealth status was granted in 1935, preparatory to a planned full independence from the United States in 1946. Preparation for a fully sovereign state was interrupted by the Japanese occupation of the islands during World War II. After the end of the war, the Treaty of Manila established the Philippine Republic as an independent nation.
With a promising economy in the 1950s and 1960s, the Philippines in the late 1960s and early 1970s saw a rise of student activism and civil unrest against President Ferdinand Marcos who declared martial law in 1972.[not in citation given] The peaceful and bloodless People Power Revolution of 1986, however, brought about the ousting of Marcos and a return to democracy for the country. The period since then, however, has been marked by political instability and hampered economic productivity.