Meade caught up with the Confederate army at Monteray Pass but did not attack at first. The Union army managed to position themselves next to the Confederates in the dark and rain without being detected. Just after 3:00 A.M., the Union cavalry came charging out of the dark into the rear of the wagon train and struck the Confederates. After a brief fight, the Confederates drove off the cavalry, but not before suffering even more casualties and slowing the withdrawal. On the 7th, Imboden stopped Buford's Union cavalry from occupying Williamsport and destroying Confederate trains. Kilpatrick's cavalry division drove 2 Confederate cavalry brigades through Hagerstown before being forced to retire by the arrival of the rest of Stuart's command. Lee's infantry reached the rain-swollen Potomac River but could not cross, the pontoon bridge having been destroyed by a cavalry raid.
French got to Williamsport before the Confederates and destroyed the pontoon bridges as ordered. Knowing that it would take at least 6 days to get everybody across, including eguipment, Lee decided to make a stand against the Union army before he proceeded with his retreat. Lee's defenses were from Downsville around to Falling Waters on Concoteague Creek, both ends of the 5 mile line secured by water.
On the 11th, Lee entrenched a line, protecting the river crossings at Williamsport and waited for Meade's army to advance. On the 12th, Meade reached the vicinity and started placing his army in an offensive position. He soon probed the Confederate line. On the 13th, skirmishing was heavy along the lines as Meade positioned his forces for the final attack. Also on the same day, the Confederates tore down all the warehouses and buildings around their defensive line, and built some wooden bridges to cross the river, all the while waiting for the Union attack. Most of the Confederate army had crossed the river by early morning on the 14th when the Union attack began.
On July 16, Gregg's cavalry approached Shepherdstown where Fitzhugh Lee's and J.R. Chambliss's brigades, supported by M.J. Ferguson's, held the Potomac River fords against the Union infantry. Fitzhugh Lee and Chambliss attacked Gregg, who held out against several attacks and sorties, fighting sporadically until nightfall when he withdrew. By the time the last Confederates crossed the river, they had lost even more men and with the Union army capturing almost 1,500 more Confederates.
By the end of the day, Lee had his army back home in Virginia. Meade had stopped Lee's threat to Washington and prevented the Confederacy from achieving foreign recognition. No Union troops had been pulled out of the Vicksburg siege as Lee had hoped, and that city fell into Union hands on July 4, one day after the Battle of Gettysburg came to a conclusion.
Combined, the 2 armies suffered over 51,000 men killed, wounded, missing, and captured. Gettysburg was the costliest battle of the war and marked the turning point in the East. The Civil War would still not come to a conclusion for another 2 years, but the Confederates, for the most part, would remain on the defensives, while the Union army, once Grant takes command later in the year, would remain primarily on the offensive.