<P> After an period of delegation of authority of the crown of Castile in the Americas and rewards to Christopher Columbus and his heirs and to conquerors in the central areas of Mexico and Peru, the crown asserted control over those territories . There were fewer constraints on royal power in its overseas territories than on the peninsula . It established control over trade and immigration through the House of Trade (1503); high courts audiencias, starting in 1511 in Santo Domingo and 1527 in Mexico; and a council devoted to overseeing governance in the overseas empire, the Council of the Indies (1524), based in Spain . It also established viceroyalties first in Mexico (1535) and Peru (1544). In the religious sphere, the crown of Castile was granted a concession by the papacy in 1501 and 1508 the power of appointment of ecclesiastical positions, administer ecclesiastical jurisdictions, and even veto papal bulls . The organization of governance of the overseas empire established under the Hapsburg monarchy was significantly reformed in the late eighteenth century by the Bourbon monarchs . </P> <P> Spain had claimed the Caribbean, all of North America and most of South America, with the exception of Brazil, which was claimed by Portugal . But other European powers did not recognize the division of territory between Spain and Portugal . English, Dutch and French settlements on the mainland of North America and in the Caribbean islands complicated the situation in the Americas . The Portuguese pressed for further territory in South America, codified by the Treaty of San Ildefonso (1777), but Spain gained the Mediterranean port of Ceuta from Portugal in the Treaty of Lisbon in 1668 . In 1704 Britain gained Gibraltar, which Spain still claims . Following Britain's seizure of the key Spanish ports of Havana, Cuba and Manila, the Philippines, in the Seven Years' War, Spain stepped up military measures to secure its empire, establishing missions and presidios in Mexico's northern frontier, particularly in California over concerns about Russian colonization of the Americas . Spain aided the Thirteen Colonies in their successful war of independence, but Spain soon found the United States directly bordering Mexico . Spain was persuaded to return the Louisiana Territory to France in 1800 . Napoleon Bonaparte Louisiana Purchase then sold it to the United States in 1803 . </P> <P> Napoleon Bonaparte's invasion of Iberia, forcing the abdication of Charles IV and replacing him with Bonaparte's brother Joseph, produced unforeseen changes in Spain and its overseas empire . The outbreak of the Spanish American wars of independence was a result of Napoleon's destabilizing actions in Spain and led to the fragmentation of the former viceroyalties into independent nation - states . Royal government disappeared and local strongmen emerged in the Spanish American republics in the wake of these wars . </P> <P> During the 15th century, Castile and Portugal became territorial and commercial rivals in the Atlantic . Portugal was first in expansion, but Castile laid claim to the Canary Islands (1402) and retook territory from the Moors in 1462 . Castile and Portugal came to formal agreements over the division of new territories in the Treaty of Alcaçovas (1479) and then the Treaty of Tordesillas (1494), following the voyage by Christopher Columbus in 1492 to the New World . </P>

What caused spain to lose its influence in the new world