As Federal positions collapsed both north and west of town, Gen. Howard ordered a retreat to the high ground south of town at Cemetery Hill, where he had left the division of Brig. Gen. Adolph von Steinwehr as a reserve.  Maj. Gen. Winfield S. Hancock assumed command of the battlefield, sent by Meade when he heard that Reynolds had been killed. Hancock, commander of the II Corps and his most trusted subordinate, was ordered to take command of the field and to determine whether Gettysburg was an appropriate place for a major battle.  Hancock told Howard, who was technically superior in rank, "I think this the strongest position by nature upon which to fight a battle that I ever saw." When Howard agreed, Hancock concluded the discussion: "Very well, sir, I select this as the battle-field." Hancock's determination had a morale-boosting effect on the retreating Union soldiers, but he played no direct tactical role on the first day. 
After suffering large casualties on the third day, Lee’s hope of a successful attack to the North vanished. He waited for the Union’s counter-offensive on July 4, however that did not happen. That night, the rain fell heavily and General Lee withdrew his devastated army toward Virginia. General Meade did not pursue the rival after Gettysburg. Nonetheless, the encounter was a serious defeat to the Confederacy. Lee army suffered a casualty of around 23,000 men, which was about a third of his army. General Lee was left discouraged by the defeat, and presented his resignation to President Jefferson. The president refused the resignation and Lee continued being the commander for the rest of the war.
Taking refuge in the bed of an unfinished railroad, Davis' troops desperately fought back as Union troops formed in their front and then charged the Southerners. At the center of the charge was Lieutenant Colonel Rufus R. Dawes whose 6th Wisconsin Infantry, also from the Iron Brigade, successfully trapped many of the Confederates in the deepest section of the Railroad Cut . Sgt. Frank Waller wrested the colors of the 2nd Mississippi Infantry from the flag bearer in the railroad bed during the short, deadly struggle. There was no escape for the Southerners in the cut soon covered by members of the 6th Wisconsin, 95th New York and the 14th Brooklyn (84th New York), which threw troops across the railroad bed west of the cut. Mercifully the Union troops held their fire and called for the Confederates to surrender. Over 200 men from Davis' brigade were now prisoners.