<P> Santo Domingo likewise declared independence in 1821 and began negotiating for inclusion in Bolivar's Republic of Gran Colombia, but was quickly occupied by Haiti, which ruled it until an 1844 revolution . Then after 17 years of independence, in 1861, Santo Domingo was again made a colony due to Haitian aggressions, yet by 1865 Santo Domingo again declared independence, making it the only territory which Spain recolonized . After 1865, then, only Cuba and Puerto Rico--and on the far side of the globe, the Philippines, Guam and nearby Pacific islands--remained in Spanish hands in the New World . </P> <P> In devastated Spain, the post-Napoleonic era created a political vacuum, broke apart any traditional consensus on sovereignty, fragmented the country politically and regionally and unleashed wars and disputes between progressives, liberals and conservatives . The instability inhibited Spain's development, which had started fitfully gathering pace in the previous century . A brief period of improvement occurred in the 1870s when the capable Alfonso XII of Spain and his thoughtful ministers succeeded in restoring some vigour to Spanish politics and prestige, but this was cut short by Alfonso's early death . </P> <P> An increasing level of nationalist, anti-colonial uprisings in various colonies culminated with the Spanish--American War of 1898, fought primarily over Cuba . Military defeat was followed by the independence of Cuba and the cession, for US $20 million, of Puerto Rico, the Philippines, and Guam to the United States . On 2 June 1899, the second expeditionary battalion "Cazadores" of Philippines the last Spanish garrison in the Philippines, located in Baler, Aurora, was pulled out, effectively ending around 300 years of Spanish hegemony in the archipelago . Its American and Asian presence ended, Spain then sold its remaining Pacific Ocean possessions to Germany in 1899, retaining only its African territories . </P> <P> By the end of the 17th century, only Melilla, Alhucemas, Peñón de Vélez de la Gomera (which had been taken again in 1564), Ceuta (part of the Portuguese Empire since 1415, has chosen to retain its links to Spain once the Iberian Union ended; the formal allegiance of Ceuta to Spain was recognized by the Treaty of Lisbon in 1668), Oran and Mazalquivir remained as Spanish territory in Africa . The latter cities were lost in 1708, reconquered in 1732 and sold by Charles IV in 1792 . </P>

Administrative structure of spanish and portuguese colonial empire