During the Maryland Campaign, the 23rd Pennsylvania guarded the Potomac River from White's Ferry to Nolen's Ferry, along with the 36th New York Infantry. During this time, it lost one officer and twenty-four men captured. In late September, it was transferred to the VI Corps. The 23rd didn't fight in the first Battle of Fredericksburg, but did in the Second Battle of Fredericksburg. The unit had not been assigned an active role in the fighting, but when it saw another regiment rout, it charged in without orders, helping carry Marye's Heights. It saw more action at the subsequent Battle of Salem Church.