The obvious failure of all efforts to secure reform then led Andres Bonifacio, a self-taught man without formal education, to found a secret society, the Katipunan, in 1892. An organization influenced by the freemasons, at the national, provincial and municipal level. Emilio Jacinto, known as the brains of the Katipunan, wrote a propaganda material directed at the widest public. The objects of the society were civic and moral as well as political. They published a journal, Kalayaan (Freedom), but only one issue was able to appear. The movement spread rapidly, but made no appeal to the middle classes who might have financed the military equipment it needed. Rizal was arrested on the point of leaving to Cuba and ordered to return to Fort Santiago in Manila to stand trial for rebellion and treason. He was found guilty and shot by a firing squad on December 30, 1896. His execution gave the rebellion fresh determination and gave inspiration to the final revolt against Spain. The activities of the Katipunan were discovered by the Spanish authorities in 1896, and its leaders fled, calling on the country to rise. They soon gained control of several provinces; but the movement then split into two factions and after two encounters with the rival separatists led by Emilio Aguinaldo; Bonifacio was sentenced to death and executed by Aguinaldo’s forces in 1897.
It was 1 November 1897 when the first Philippine Republic and its constitution were declared with Aguinaldo as President. The Pact of Biak-na-Bato was signed by both parties under the agreement a general amnesty will be extended to the rebels and a payment of US$800,000 for Aguinaldo and his government to retire and voluntary exile in Hong Kong.
On 25 April 1898 the United States declared war on Spain, few days later Commodore George Dewey sank the Spanish fleet at anchor in Manila. Meanwhile the Filipinos had taken up arms again and concerted with the Americans. They were encircling the Spanish forces which had sought refuge in Intramuros. On 13 August the Spaniards surrendered. Aguinaldo, who had returned to the Philippines with a supply of arms, now hoped that the Americans would support his new Republic. Assisted by the advice of a lawyer named Apolinario Mabini, he had established the dictatorship of Malolos in May, and in the following month this became the revolutionary government. Aguinaldo then summoned a parliament to discuss and approve a constitution; and the independence of the Philippines was declared on 12 June 1898 and the new constitution introduced on 21 January 1899. The prime objective of this haste was to prove to international opinion that the new nation was able to govern itself and to secure recognition by foreign powers.
On 10 December 1898, however, the United States and Spain signed the Treaty of Paris, under which the Philippines were ceded to the United States together with Guam and Puerto Rico for the amount of US$20 million. It was 6 February 1899, when the treaty was ratified by the U.S. Senate and the Filipinos had not even been consulted. The destruction of Filipino hopes that the Americans would support their allies in their struggle to achieve independence led to tension between the two countries which soon exploded into conflict. The Filipinos put up fierce resistance all over the country, and the Americans had to conquer it again, region by region. Aguinaldo was captured in March 1901, in spite of the efforts of his courageous generals Antonio Luna, Gregorio del Pilar and Miguel Malvar. Macario Sakay, however, continued the struggle until 1906, and was finally induced to surrender only by an American promise to establish a National Assembly when peace was restored.