In the Gettysburg Campaign, as part of a general shuffling of senior officers when Maj. Gen. George Meade was promoted from commander of the V Corps to be commander of the Army of the Potomac and Maj. Gen. George Sykes took command of the corps, Ayres was promoted to command the Regular Division. He had risen to division command quickly for an officer with little infantry experience. At the Battle of Gettysburg, he did not have an opportunity to shine in his new assignment. His division arrived on the battlefield around midday on the second day of battle, July 2, 1863. After a brief rest in camp near Power's Hill, two brigades from his division were sent to reinforce Union troops from Maj. Gen. John C. Caldwell's division (II Corps), which was counterattacking Confederate forces in the Wheatfield. Due to a great Confederate assault nearby at the Peach Orchard, Caldwell's division retreated so that his two brigades were at risk of being surrounded. They were forced to retreat as well, suffering heavy casualties. Nevertheless, Ayres received praise for his performance and he received a brevet promotion to major in the regular army for his actions at Gettysburg. After the battle, the Regular Division was sent in New York City to suppress the draft riots there.