In the late eighteenth and early nineteenth centuries, Creek people and other Native Americans, and free and fugitive African Americans sought refuge in Florida. The Seminole people formed. After foreign colonial rule shifted between Spain and Great Britain and back again, in 1821 the United States acquired the territory of Florida. After warfare to the north, in 1827 the U.S. Army built Fort King near the present site of Ocala as a buffer between the Seminole, who had long occupied the area, and white settlers moving into the region. The fort was an important base during the Second Seminole War and later served in 1844 as the first courthouse for Marion County.