During the 19th century Spain invested heavily in education and infrastructure. Through the Education Decree of December 20, 1863, Queen Isabella II of Spain decreed the establishment of a free public school system that used Spanish as the language of instruction, leading to increasing numbers of educated Filipinos.  Additionally, the opening of the Suez Canal in 1869 cut travel time to Spain, which facilitated the rise of the ilustrados, an enlightened class of Filipinos that had been able to expand their studies in Spain and Europe.
Puente de Claveria (Quezon Bridge) A great deal of infrastructure projects were undertaken during the 19th century that put the Philippine economy and standard of living ahead of most of its Asian neighbors and even many European countries at that time. Among them were a railway system for Luzon, a tramcar network for Manila, and the Puente Colgante (now known as the Quezon Bridge), Asia’s first steel suspension bridge. 83] On August 1, 1851 the Banco Espanol-Filipino de Isabel II was established to attend the needs of the rapid economic boom, that had greatly increased its pace since 1840 as a result of a new economy based on a rational exploitation of the agricultural resources of the islands.
The increase in textile fiber crops such as abaca, oil products derived from the coconut, indigo, that was growing in demand, etc. generated an increase in money supply that led to the creation of the bank. Banco Espanol-Filipino was also granted the power to print a Philippine-specific currency (the Philippine peso) for the first time (before 1851, many currencies were used, mostly the pieces of eight). Spanish Manila was seen in the 19th century as a model of colonial governance that effectively put the interests of the original inhabitants of the islands before those of the colonial power.
As John Crawfurd put it in its History of the Indian Archipelago, in all of Asia the “Philippines alone did improve in civilization, wealth, and populousness under the colonial rule” of a foreign power.  John Bowring, Governor General of British Hong Kong from 1856 to 1860, wrote after his trip to Manila: Credit is certainly due to Spain for having bettered the condition of a people who, though comparatively highly civilized, yet being continually distracted by petty wars, had sunk into a disordered and uncultivated state.
The inhabitants of these beautiful Islands upon the whole, may well be considered to have lived as comfortably during the last hundred years, protected form all external enemies and governed by mild laws vis-a-vis those from any other tropical country under native or European sway, owing in some measure, to the frequently discussed peculiar (Spanish) circumstances which protect the interests of the natives.
In The inhabitants of the Philippines, Frederick Henry Sawyer wrote: Until an inept bureaucracy was substituted for the old paternal rule, and the revenue quadrupled by increased taxation, the Filipinos were as happy a community as could be found in any colony. The population greatly multiplied; they lived in competence, if not in affluence; cultivation was extended, and the exports steadily increased.
Let us be just; what British, French, or Dutch colony, populated by natives can compare with the Philippines as they were until 1895?.  The first official census in the Philippines was carried out in 1878. The colony’s population as of December 31, 1877, was recorded at 5,567,685 persons.  This was followed by the 1887 census that yielded a count of 6,984,727, while that of 1898 yielded 7,832,719 inhabitants .  The estimated GDP per capita for the Philippines in 1900, the year Spain left, was of $1,033. 00. That made it the second richest place in all of Asia, just a little behind Japan ($1,135. 00), and far ahead of China ($652. 00) or India ($625. 00).  Philippine Revolution Main article: Philippine Revolution
Revolutionary sentiments arose in 1872 after three Filipino priests, Mariano Gomez, Jose Burgos, and Jacinto Zamora, known as Gomburza, were accused of sedition by colonial authorities and executed. This would inspire the Propaganda Movement in Spain, organized by Marcelo H. del Pilar, Jose Rizal, Graciano Lopez Jaena, and Mariano Ponce, that clamored for adequate representation to the Spanish Cortes and later for independence. Jose Rizal, the most celebrated intellectual and radical ilustrado of the era, wrote the novels “Noli Me Tangere”, and “El filibusterismo”, which greatly inspired the movement for independence.
The Katipunan, a secret society whose primary purpose was that of overthrowing Spanish rule in the Philippines, was founded by Andres Bonifacio who became its Supremo (leader). An early flag of the Filipino revolutionaries The Philippine Revolution began in 1896. Rizal was wrongly implicated in the outbreak of the revolution and executed for treason in 1896. The Katipunan in Cavite split into two groups, Magdiwang, led by Mariano Alvarez (a relative of Bonifacio’s by marriage), and Magdalo, led by Emilio Aguinaldo.
Leadership conflicts between Bonifacio and Aguinaldo culminated in the execution or assassination of the former by the latter’s soldiers. Aguinaldo agreed to a truce with the Pact of Biak-na-Bato and Aguinaldo and his fellow revolutionaries were exiled to Hong Kong. Not all the revolutionary generals complied with the agreement. One, General Francisco Makabulos, established a Central Executive Committee to serve as the interim government until a more suitable one was created. Armed conflicts resumed, this time coming from almost every province in Spanish-governed Philippines.
Revolutionaries gather during the Malolos congress of the First Philippine Republic. In 1898, as conflicts continued in the Philippines, the USS Maine, having been sent to Cuba because of U. S. concerns for the safety of its citizens during an ongoing Cuban revolution, exploded and sank in Havana harbor. This event precipitated the Spanish–American War.  After Commodore George Dewey defeated the Spanish squadron at Manila, a German squadron arrived in Manila and engaged in maneuvers which Dewey, seeing this as obstruction of his blockade, offered war—after which the Germans backed down.
The German Emperor expected an American defeat, with Spain left in a sufficiently weak position for the revolutionaries to capture Manila—leaving the Philippines ripe for German picking.  The U. S. invited Aguinaldo to return to the Philippines in the hope he would rally Filipinos against the Spanish colonial government. Aguinaldo arrived on May 19, 1898, via transport provided by Dewey. By the time U. S. land forces had arrived, the Filipinos had taken control of the entire island of Luzon, except for the walled city of Intramuros.
On June 12, 1898, Aguinaldo declared the independence of the Philippines in Kawit, Cavite, establishing the First Philippine Republic under Asia’s first democratic constitution.  In the Battle of Manila, the United States captured the city from the Spanish. This battle marked an end of Filipino-American collaboration, as Filipino forces were prevented from entering the captured city of Manila, an action deeply resented by the Filipinos.  Spain and the United States sent commissioners to Paris to draw up the terms of the Treaty of Paris which ended the Spanish–American War.
The Filipino representative, Felipe Agoncillo, was excluded from sessions as the revolutionary government was not recognized by the family of nations.  Although there was substantial domestic opposition, the United States decided to annex the Philippines. In addition to Guam and Puerto Rico, Spain was forced in the negotiations to hand over the Philippines to the U. S. in exchange for US$20,000,000. 00.  U. S. President McKinley justified the annexation of the Philippines by saying that it was “a gift from the gods” and that since “they were unfit for self-government, … here was nothing left for us to do but to take them all, and to educate the Filipinos, and uplift and civilize and Christianize them”, in spite of the Philippines having been already Christianized by the Spanish over the course of several centuries. It is also in spite of the Spanish having created the first public education system in Asia (public education decree of 1863) and the first universities in the continent: University of Santo Tomas in 1611, and University of San Carlos (Cebu) in 1595. It was also clearly a misrepresentation to state that the Philippines needed to be “civilized”.
The archipelago saw rapid growth and development during Spanish rule thanks to the introduction of many elements of Western civilization, including irrigation, the plow and the wheel, new construction and engineering methods, factories, modern hospitals, the telephone and the telegraph, railroads and public lighting. By 1898 the Philippines was one of the most advanced countries in Asia, producing great statesmen, writers and scientists such as national hero Jose Rizal. The first Philippine Republic resisted the U. S. occupation, resulting in the Philippine–American War (1899–1913).