Although not recognized as such by Mexico, Texas declared itself an independent nation, the Republic of Texas. Attracted by the rich lands for cotton plantations and ranching, tens of thousands of immigrants arrived from the U.S. and from Germany as well. In 1845, Texas joined the United States, becoming the 28th state, when the United States annexed it. Only after the conclusion of the Mexican–American War, with the Treaty of Guadalupe Hidalgo in 1848, did Mexico recognize Texan independence. Texas declared its secession from the United States in 1861 to join the Confederate States of America. Only a few battles of the American Civil War were fought in Texas; most Texas regiments served in the east. When the war ended, enslaved African Americans were freed after ratification of the Emancipation Proclamation. Texas was subject to Reconstruction after the Civil War was over. Later on, White democrats gained political dominance and passed laws in the late 19th century creating second-class status for blacks in a Jim Crow system of segregation and which included disenfranchising them from voting in 1901 through passage of a poll tax. Black residents were excluded from the formal political system until after passage of federal civil rights legislation in the mid-1960s.