As the 4th Pennsylvania's three-month enlistment ran out, most of its members reenlisted in the 51st P.V. during the fall of 1861. Composed of men from Centre, Montgomery, Northampton, Snyder, and Union counties, the unit was under the command of John F. Hartranft, who would later become the state's governor for two consecutive terms and commander of the Pennsylvania National Guard. After spending the first six months of service in North Carolina, the 51st was sent as reinforcements to Virginia and remained a part of the Ninth Corp throughout its term of service. In September 1862 the regiment was sent into Maryland to stop Lee's invasion.
On September 17, 1862 the two armies clashed at Antietam Creek near the small town of Sharpsburg, Maryland. In the early stages of the battle, Union forces unsuccessfully tried to cross the now-famous stone bridge on the left flank. By mid-afternoon the 51st was ordered to take the bridge. With support from the 51st New York Infantry, Colonel Hartranft and the 51st Pennsylvania charged over open ground toward the bridge. The opposing force was well entrenched on a hill on the opposite shore. After a gallant charge, the color-bearers of the 51st, lead by Captain William Allebaugh of Company C., were the first Union soldiers to reach the opposite shore. The regiment continued up the hill on the opposite bank and forced Brigadier General Robert Toombs' Confederate regiment to retreat. The flags carried by the 51st were "much abused" in this charge, and the flagstaff of the state color was badly damaged. The 51st suffered numerous casualties with twenty-one men killed and ninety-nine wounded.