Since 1803 the United States and Spain had argued about the exact boundaries of the Louisiana Purchase. The Spanish controlled territory to the south and west of the Louisiana Purchase. Spain also controlled Florida.
In 1810 and again in 1813, during the War of 1812, the United States had seized portions of what was called West Florida, an area along the coast of the Gulf of Mexico. But when Monroe took office in 1816 Spain still controlled East Florida.
Florida had long been a refuge for pirates, smugglers, escaped slaves, and others who wanted to escape American law. Indians from Florida would frequently raid American settlements along the border.
In 1818 President Monroe ordered General Andrew Jackson to stop these raids. Jackson, a hero of the War of 1812, chased the Indians into Florida. By leading his army across the border into Spanish territory Jackson had committed an act of war, but he went even further. Jackson captured several Spanish forts and hanged two British citizens who were found guilty of supplying weapons to the Indians!
Spain protested, but at the time Spain's power was weakening. The leaders of Spain knew they could not hold on to Florida if the United States decided to take it from them. So, instead of declaring war they decided to make a deal.
In 1819 a treaty was signed in which Spain agreed to cede, or give, Florida to the United States. In return, the U.S. agreed to pay $5 million which the Spanish government owed to American citizens. Thus, all of Florida was added to a growing United States.