The Captaincy General of the Philippines ( ; ) was an administrative district of the Spanish Empire in Southeast Asia governed by a governor-general as a dependency of the Viceroyalty of New Spain based in Mexico City until Mexican independence when it was transferred directly to Madrid. The Captaincy General encompassed the Spanish East Indies, which included among others the Philippine Islands, the Mariana Islands, and the Caroline Islands. It was founded in 1565 with the first permanent Spanish forts. For centuries, all the administrative, political and economic aspects of the Captaincy General were administered in Mexico City by the Viceroyalty of New Spain for the Spanish Crown. However, in 1821, following the independence of the Mexican empire, all control was transferred to Madrid. It was succeeded by the short-lived First Philippine Republic following its independence through the Philippine Revolution. History Early explorations After a long, tolling voyage across the Pacific Ocean, Ferdinand Magellan reached the island of Guam on 6 March 1521 and anchored the three ships that were left of his fleet in Umatac Bay, before proceeding to the Philippines, where he met his death during the Battle of Mactan. Antonio Pigafetta, the expedition's chronicler and one of only 18 original crew members to survive Ferdinand Magellan's circumnavigation of the globe, recorded all details of the voyage. Miguel López de Legazpi arrived in Umatac in 1565 and claimed the island of Guam for Spain, before proceeding to the Philippines, where, in a short period of time, they successfully incorporated into Spain's empire Cebu, Samar, Mazaua, Leyte, and Bohol, before conquering Manila. Later (in 1569), Miguel López de Legazpi transferred the Spanish headquarters from Cebu to Panay, where they found allies, who were never conquered by Spain but were accomplished as vassals by means of pacts, peace treaties, and reciprocal alliances. On 5 June 1569, Guido de Lavezaris, the royal treasurer in the archipelago, wrote to Philip II reporting about the Portuguese attack on Cebu in the preceding autumn. A letter from another official, Andres de Mirandaola (dated three days later, on 8 June), also described briefly this encounter with the Portuguese. The danger of another attack led the Spaniards to remove their camp from Cebu to Panay, which they considered a safer place. Legazpi himself, in his report to the Viceroy in New Spain (dated 1 July 1569), mentioned the same reason for the relocation of Spaniards to