Gen. Lockwood commanded a brigade attached to XII Corps at the Battle of Gettysburg in July 1863. His brigade was kept directly under corps headquarters control during the battle, because the acting corps commander, Brig. Gen. Alpheus S. Williams, did not want an unknown officer commanding 1st Division just because he was senior to Brig. Gen. Thomas H. Ruger. The brigade was absorbed into the division after Williams returned to that command and Maj. Gen. Henry W. Slocum resumed corps command. In the winter of 1863–64 Lockwood commanded the Middle Department, with headquarters at Baltimore, Maryland. Later he commanded provisional troops against General Jubal A. Early during his raid of July 1864. During the Battle of Spotsylvania Courthouse General John C. Robinson was severely wounded leading the 2nd Division of the V Corps. The division was ultimately broken up and dispersed among other division commanders for the remainder of the battle. The division was resembled and Lockwood was assigned to command on May 29 during the Battle of Totopotomoy Creek. On June 2, the Pennsylvania Reserves of the 3rd Division were mustered out. All remaining soldiers of that division, along with General Samuel W. Crawford were assigned to the 2nd Division. Corps commander, Maj. Gen. Gouverneur K. Warren, sent the former academic back to the Middle Department because did not think Lockwood sufficiently competent for so high a rank.