The Compromise of 1877 is considered the formal end of Reconstruction. The Presidential election of 1876 was between Republican Rutherford B. Hayes and Samuel Tilden, a famous prosecutor from New York City who had brought down Boss Tweed.
Only Republicans had won since Lincoln was elected and the Civil War split the Democratic Party. Hayes, in this case, was a pretty weak candidate, so the party pulled some strings and cheated him into office. The soldiers who were running the elections in four southern states changed the electoral results so that Hayes would win by one vote. The problem was, everyone knew it. It was obvious.
There was a stalemate and weeks went by with no one knowing who the real President would be.
So the final agreement went as follows:
1) Hayes would get to be President, even though he cheated
2) A southerner would be on Hayes' Cabinet
3) A railroad would be constructed across the South
4) Most importantly, Union troops would leave the Southern states
This meant that the Civil War amendments could not be enforced, freed slaves could not be protected, and Reconstruction effectively ends.
Hayes was very ineffective as President, since everyone knew he cheated. A newspaper headline after the Compromise read: "Hail to the Thief" instead of Hail to the Chief.