forces were close to the Confederate line and poised to attack the Confederate flank, the important road junction of Five Forks and the two Confederate railroad lines to Petersburg and Richmond that remained open to the two cities. On April 2–3, 1865, the Confederates evacuated Petersburg and Richmond and began to move to the west. After a number of setbacks and mostly small battles, but including a significant Confederate defeat at the Battle of Sailor's Creek on April 6, 1865, Lee surrendered his army to Grant and his pursuing Union Army on April 9, 1865 at Appomattox Court House, about 25 miles (40 km) east of Lynchburg, Virginia. By the end of June 1865, all Confederate armies had surrendered and the Confederacy's government had collapsed. Background Military situation Richmond–Petersburg Campaign On June 15–18, 1864, two Union Army corps, moved unobserved from the stalemated battle lines just north of Richmond across the James River to the south of Petersburg, Virginia. The Union force which joined with the Union Army of the James at Petersburg failed to seize the city from a small force of Confederate defenders at the Second Battle of Petersburg. By June 18, 1864, the Army of Northern Virginia had reinforced the defenders and the 292-day Richmond–Petersburg Campaign (Siege of Petersburg) had begun. Grant's strategy had to become a campaign of trench warfare attrition in which the Union forces tried to wear down the Confederate Army, destroy or cut off sources of supply and supply lines to Petersburg and Richmond and to extend the lines which the outnumbered and declining Confederate force had to defend to the breaking point. During the rest of 1864 and early 1865, Grant slowly moved his forces in the Union line south of Petersburg to the west in six more Petersburg offensives, usually with simultaneous attacks at or near the Richmond lines. The Confederates extended their lines to compensate for these moves, but they were stretched increasingly thin. With supplies and men increasingly hard for Lee to obtain or replace, he knew that his army could not defend Petersburg and Richmond from the growing Union forces indefinitely, especially with the expected arrival of Union reinforcements from recent recruits in training, Major General Philip Sheridan's cavalry divisions from the Shenandoah Valley and possibly even Major General William T. Sherman's armies already operating in North Carolina when the roads dried out after spring rains abated. After