https://en.wikipedia.org/wiki/Reconstruction_era
When President Abraham Lincoln, a Republican, was assassinated at the end of the Civil War, Vice President Andrew Johnson, a Democrat from Tennessee and former slave holder, became President. Johnson favored rapid measures to bring the South back into the Union, allowing the southern states to determine the rights of former slaves. Radical Republicans in Congress sought stronger, federal measures to upgrade the rights of African Americans, including the Fourteenth Amendment to the United States Constitution, while curtailing the rights of former Confederates...
...Elected in 1868, Republican President Ulysses S. Grant supported Congressional Reconstruction and enforced the protection of African Americans in the South through the use of the Enforcement Acts passed by Congress. Grant used the Enforcement Acts to effectively combat the Ku Klux Klan, which was essentially wiped out,
... public support for Reconstruction policies, requiring continued supervision of the South, faded in the North after the Democrats, who strongly opposed Reconstruction, regained control of the House of Representatives in 1874. In 1877, as part of a Congressional bargain to elect Republican Rutherford B. Hayes as president following the disputed 1876 presidential election, U.S. Army troops were withdrawn from the three states (South Carolina, Louisiana, and Florida) where they still remained. This marked the end of Reconstruction.