Black Codes were a series of laws passed after the completion of the U.S. Civil War in the 1860s. They were passed by the governments of several states in the southern United States as a means of keeping freed slaves from gaining rights equal to those of white men. These laws had their origins in the Slave Codes that existed before the 13th Amendment to the U.S. Constitution ended slavery in the U.S.
Among the codes were laws that denied blacks the right to own property, testify in court or serve on a jury, choose their profession, or vote in elections. When the Republican Party dominated the U.S. elections of 1866, it used its newly-gained power to repeal the codes.
Even after the Civil War and the 13th Amendment gained blacks freedom from slavery, in the southern U.S., they still faced segregation and persecution at nearly the same level as when they were slaves. The Black Codes were quickly passed into law in the Southern states as a way to prevent any black uprisings and deprive blacks from any semblance of autonomy, while keeping white Southern landowners in positions of power. With President Andrew Johnson among those who still considered blacks an inferior race, there was little chance for blacks to build on their supposed freedom.
Building upon the Slave Codes that had previously been in place, these laws differed from state to state but generally imposed many of the same restrictions on blacks. Not only were they designed to inhibit the freedoms of the blacks, but they were also intended to provide a steady source of labor for Southern landowners now deprived of slaves. For this reason, many of the codes attempted to limit the opportunity for blacks to choose an occupation, relegating them to their antebellum occupations as servants and agricultural workers.
Personal freedoms were also severely restrained. Blacks weren't allowed to marry outside their own race, and laws were put in place that made it nearly impossible for them to own property. They were also prevented from moving freely from town to town or even being out at night without a specific purpose. In addition, they were denied from voting and couldn't serve in any capacity in a court case which involved whites.
All of these laws served the purpose of sustaining the pre-war notion of black people as nothing more than property. In the 1866 elections, the radical arm of the Republican Party dominated the elections in the South. With this change of power in place, the majority of the most notorious Black Codes were repealed, even though segregation of blacks in the South persisted well into the 20th century.