As part of the Adams-Onis Treaty of 1818, Spain ceded both East and West Florida to the United States. On July 10, 1821, the 23-star flag of the United States replaced the Spanish flag above the Castillo de San Marcos and, during the Territorial Period (1821-1845), the Castillo de San Marcos was renamed Fort Marion. On July 21, 1821, Florida Territorial Governor Andrew Jackson officially established St. Johns County. In 1845, 24 years after the U.S. flag was hoisted above the Castillo, Florida became the 27th State.