Tensions between slave and free states mounted with arguments over the relationship between the state and federal governments, as well as violent conflicts over the spread of slavery into new states. Abraham Lincoln, candidate of the largely antislavery Republican Party, was elected president in 1860. Before he took office, seven slave states declared their secession—which the federal government maintained was illegal—and formed the Confederate States of America. With the Confederate attack upon Fort Sumter, the American Civil War began and four more slave states joined the Confederacy. Lincoln's Emancipation Proclamation in 1863 declared slaves in the Confederacy to be free. Following the Union victory in 1865, three amendments to the U.S. Constitution ensured freedom for the nearly four million African Americans who had been slaves,made them citizens, and gave them voting rights. The war and its resolution led to a substantial increase in federal power.
After the war, the assassination of Lincoln radicalized Republican Reconstruction policies aimed at reintegrating and rebuilding the Southern states while ensuring the rights of the newly freed slaves. The resolution of the disputed 1876 presidential election by the Compromise of 1877 ended Reconstruction; Jim Crow laws soon disenfranchised many African Americans. In the North, urbanization and an unprecedented influx of immigrants from Southern and Eastern Europe hastened the country's industrialization. The wave of immigration, lasting until 1929, provided labor and transformed American culture. National infrastructure development spurred economic growth. The 1867 Alaska purchase from Russia completed the country's mainland expansion. The Wounded Knee massacre in 1890 was the last major armed conflict of the Indian Wars. In 1893, the indigenous monarchy of the Pacific Kingdom of Hawaii was overthrown in a coup led by American residents; the United States annexed the archipelago in 1898. Victory in the Spanish–American War the same year demonstrated that the United States was a world power and led to the annexation of Puerto Rico, Guam, and the Philippines.The Philippines gained independence a half-century later; Puerto Rico and Guam remain U.S. territories.