The Philippine population lived an agrarian lifestyle until the islands were colonized by the Spanish. Magellan claimed the islands for Spain in 1521, and one month later was killed by a tribal chief. Permanent Spanish settlement was finally established in 1565, and Spanish occupation was marked by various types of resistance which are still topics of Filipino stories and songs today. The first phase of United States rule, in 1898, was ostensibly put in place with the goal of establishing Philippine self-rule, though regulations regarding such things as migration and trade were heavily weighted in favor of the United States, and Filipinos chafed at continued occupation. Under General Emilio Aguinaldo (later the first Philippine President), the first declaration of independence from Spain was presented to the public on June 12, 1898, but independence from the United States was not officially declared by the government until July 4, 1946.