Cartoon by Thomas Nast, 1874, Harper’s Weekly
These were a body of laws enacted by southern U.S. states in 1865 and 1866 following the end of the Civil War in order to regain their power over the freed slaves, maintain white supremacy and ensure the continued supply of cheap labor. Although the 13th Amendment formally abolished slavery under U.S. law, the southern states considered the black codes a revival of slavery in disguise and a means through which the blacks would remain socially, politically and economically inferior. The first black codes were passed by Mississippi in November 1865. One of the vagrancy laws required all freedmen to carry evidence of employment and if they did not have it, they were subjected to being arrested or fined. Southern whites passed these laws because 1) they feared black political influence 2) they worried that freed slaves would seek revenge on their masters and rape their women 3) the blacks would ensure a stable black workforce.
The primary factor in eliminating the black codes was the takeover of the Republican Party in Congress during the Reconstruction Era which saw the creation of the 14th and 15th Amendment. However, the black codes paved the way for Jim Crow laws as southern whites were angered once again with the rights given to blacks.