Leading up to July 1, 1863, Lee (CS) moved his forces up the Blue Ridge into Pennsylvania in another campaign to draw the Army of the Potomac out of Virginia so as to defeat it in the open, then march on Washington.
The morning of July 1 found General John Buford Jr. (US) laying out a defensive line along three ridges to the North and Northwest of the tiny village of Gettysburg, Herr Ridge, McPherson Ridge, and Seminary Ridge. Knowing that the high ground was so important and that the Union forces had rarely held high ground during engagements, Buford chose the most defensive position possible to allow time for the infantry to take the field and hold the higher ground south of town at Cemetery Hill, Cemetery Ridge, and Culp's Hill.
If Lee's forces gained these high points, Meade would never be able to take them.
Buford's cavalry dismounted and fought a delaying action. Lee's forces initially had some early success North of the Gettysburg pike, but were ultimately repulsed with heavy losses.
As the battle wore on from morning into the afternoon, federal troops failed to arrive while Lee's forces solidified. By 2PM, Confederate forces under Generals Robert Rodes (CS) and Jubal Early (CS) assaulted and outflanked the forces North and Northwest of the town.
The federal positions collapsed. General Howard (US) orders a retreat. The federals retreated to Cemetery Hill. Robert E. Lee sent orders to General Richard Ewell to take Cemetery Hill if practicable. At the time Ewell received the order federal forces were in no position to easily defend, yet Ewell determined it was not practicable to assault the hill. This was the first in a series of major mistakes made by the confederates at a little town called Gettysburg.
By the end of the first day of the battle, Lee's forces were in position to assault the following morning, but the Federals held the high ground.