Spain ceded Florida to the U.S. (Adams–Onís Treaty, 1819) largely because General Andrew Jackson's 1818 invasion of Spanish Florida—ostensibly against Seminoles but exceeding orders—demonstrated Spain's inability to govern or defend the territory.
Jackson seized Pensacola and St. Marks, executed two British subjects, and effectively controlled the region. Spain, facing revolts in Latin America and U.S. pressure, chose to sell rather than fight.