By April 9th, 1865, Robert E. Lee's Army of Northern Virginia was in a state of desperation. Union forces had occupied both Petersburg and the Confederate capital of Richmond and Lee's army was forced west in a last-ditch attempt to join forces with Confederate General Joseph Johnston in North Carolina. The Confederate government had fled toward Danville in southern Virginia.
Union forces under Ulysses S. Grant cut off Lee's retreat at the village of Appomattox Courthouse. Lee originally thought his pursuers only consisted of cavalry, but when it became clear the cavalry was backed by two infantry corps, and that his weak, tired, and bedraggled army was in no shape to continue the fight, Lee had no choice but to surrender. His only option was to negotiate as favorable terms as possible for this army. On the afternoon of April 9th, Lee surrendered the Army of Northern Virginia to General Grant in the parlor of the Wilmer McLean House. Surrender terms authorized by Ulysses S. Grant were generous. No soldiers in Lee's army would be imprisoned or punished. Officers were allowed to keep their pistols and soldiers were allowed to keep their horses. In addition, Grant provided rations and food to the starving Confederate army.
Although there would be several small skirmishes following Lee's surrender, the Confederacy was defeated and within the next two months, it would be completely dissolved.