The Confederacy, officially the Confederate States of America, was an unrecognized republic formed in 1861 by eleven Southern states, primarily to preserve slavery and states' rights. It waged the American Civil War against the Union until its surrender in 1865.