On the third day of the Battle of Gettysburg, Confederate General Robert E. Lee’s last attempt at breaking the Union line ends in disastrous failure, bringing the most decisive battle of the American Civil War to an end.

In June 1863, following his masterful victory at the Battle of Chancellorsville, General Lee launched his second invasion of the Union in less than a year. He led his 75,000-man Army of Northern Virginia across the Potomac River, through Maryland, and into Pennsylvania, seeking to win a major battle on Northern soil that would further dispirit the Union war effort and induce Britain or France to intervene on the Confederacy’s behalf. The 90,000-strong Army of the Potomac pursued the Confederates into Maryland, but its commander, General Joseph Hooker, was still stinging from his defeat at Chancellorsville and seemed reluctant to chase Lee further. Meanwhile, the Confederates divided their forces and investigated various targets, such as Harrisburg, the Pennsylvania capital.

On June 28, President Abraham Lincoln replaced Hooker with General George Meade, and Lee learned of the presence of the Army of the Potomac in Maryland. Lee ordered his army to concentrate in the vicinity of the crossroads town of Gettysburg and prepare to meet the Federal army. At the same time, Meade sent ahead part of his force into Pennsylvania but intended to make a stand at Pipe Creek in Maryland.

READ MORE: How the Battle of Gettysburg Turned the Tide of the Civil War

On July 1, a Confederate division under General Henry Heth marched into Gettysburg hoping to seize supplies but finding instead three brigades of Union cavalry. Thus began the Battle of Gettysburg, and Lee and Meade ordered their massive armies to converge on the impromptu battle site. The Union cavalrymen defiantly held the field against overwhelming numbers until the arrival of Federal reinforcements. Later, the Confederates were reinforced, and by mid-afternoon some 19,000 Federals faced 24,000 Confederates. Lee arrived to the battlefield soon afterward and ordered a general advance that forced the Union line back to Cemetery Hill, just south of the town.

During the night, the rest of Meade’s force arrived, and by the morning Union General Winfield Hancock had formed a strong Union line. On July 2, against the Union left, General James Longstreet led the main Confederate attack, but it was not carried out until about 4 p.m., and the Federals had time to consolidate their positions. Thus began some of the heaviest fighting of the battle, and Union forces retained control of their strategic positions at heavy cost. After three hours, the battle ended, and the total number of dead at Gettysburg stood in the thousands.

On July 3, Lee, having failed on the right and the left, planned an assault on Meade’s center. A 15,000-man strong column under General George Pickett was organized, and Lee ordered a massive bombardment of the Union positions. The 10,000 Federals answered the Confederate artillery onslaught, and for more than an hour the guns raged in the heaviest cannonade of the Civil War. At 3 p.m., Pickett led his force into no-man’s-land and found that Lee’s bombardment had failed. As Pickett’s force attempted to cross the mile distance to Cemetery Ridge, Union artillery blew great holes in their lines. Meanwhile, Yankee infantry flanked the main body of “Pickett’s charge” and began cutting down the Confederates. Only a few hundred Virginians reached the Union line, and within minutes they all were dead, dying, or captured. In less than an hour, more than 7,000 Confederate troops had been killed or wounded.

Both armies, exhausted, held their positions until the night of July 4, when Lee withdrew. The Army of the Potomac was too weak to pursue the Confederates, and Lee led his army out of the North, never to invade it again. The Battle of Gettysburg was the turning point in the Civil War, costing the Union 23,000 killed, wounded, or missing in action. The Confederates suffered some 25,000 casualties. On November 19, 1863, President Lincoln delivered his famous Gettysburg Address during the dedication of a new national cemetery at the site of the Battle of Gettysburg. The Civil War effectively ended with the surrender of General Lee’s Army of Northern Virginia in April 1865.