When the Civil War broke out in 1861 and divided the nation, Maryland stood on the pivotal border between North and South and braced itself for war. Battles fought on Maryland soil were critical to the defense of the nation's capital and showed the region's citizens the brutality of the war firsthand. The long conflict engulfed homes, towns, and livelihoods, leaving its mark in many battlefields, while local citizens, though divided by conviction, were united by compassion as they tended the wounded in nearby churches and public buildings converted into hospitals. In the fall of 1862, Confederate General Robert E. Lee advanced through the region hoping a bold invasion of the North would liberate Maryland, but after dividing his army between Harper's Ferry, Hagerstown, and the three South Mountain gaps and then being forced back by Union resistance at the gaps, he regrouped at Sharpsburg, where the Battle of Antietam on September 17, 1862 became the bloodiest single-day battle in American history and ended his invasion despite massive losses on both sides. In the summer of 1863, more than 160,000 Union and Confederate troops moved through Maryland during the Gettysburg Campaign, with Confederate forces marching through the Great Valley while Union forces advanced north from Frederick before the armies collided at Gettysburg on July 1, 1863 in another Union victory. Maryland was invaded a third time in July 1864 when Confederate troops under General Jubal Early moved toward Washington, but although they defeated General Lew Wallace's inexperienced 2,300-man Union force stretched over 6 miles along the Monocacy River near Frederick, the battle cost precious time and spared the capital.