Over the course of 1862, Cunningham commanded Company F in combat during the battles of Second Bull Run, Antietam and Fredericksburg. In 1863, he participated in the battles of Chancellorsville, Gettysburg and Mine Run. In 1864, still in command of a company in the 32nd Massachusetts, Cunningham saw action in the Overland Campaign, a series of battles aimed at grinding down the Confederate Army of Northern Virginia and taking the Confederate capital of Richmond. The Overland Campaign ended in a stalemate and resulted in the long Siege of Petersburg.