<P> Effective October 1, 1804, the purchased territory was organized into the Territory of Orleans (most of which would become the state of Louisiana) and the District of Louisiana, which was temporarily under control of the governor and judicial system of the Indiana Territory . The following year, the District of Louisiana was renamed the Territory of Louisiana, aka Louisiana Territory (1805--1812). </P> <P> New Orleans was the administrative capital of the Orleans Territory, and St. Louis was the capital of the Louisiana Territory . </P> <P> A dispute soon arose between Spain and the United States regarding the extent of Louisiana . The territory's boundaries had not been defined in the 1762 Treaty of Fontainebleau that ceded it from France to Spain, nor in the 1801 Third Treaty of San Ildefonso ceding it back to France, nor the 1803 Louisiana Purchase agreement ceding it to the United States . </P> <P> The United States claimed Louisiana included the entire western portion of the Mississippi River drainage basin to the crest of the Rocky Mountains and land extending southeast to the Rio Grande and West Florida . Spain insisted that Louisiana comprised no more than the western bank of the Mississippi River and the cities of New Orleans and St. Louis . The dispute was ultimately resolved by the Adams--Onís Treaty of 1819, with the United States gaining most of what it had claimed in the west . </P>

Who did spain give new orleans and the rest of louisiana to in 1801