[31] Retreating into Maryland, the army was reorganized again: Major General Philip Sheridan replaced Hunter, and McKinley, who had been promoted to captain after the battle, was transferred to General Crook's staff.[32] By August, Early was retreating south in the valley, with Sheridan's army in pursuit.[33] They fended off a Confederate assault at Berryville, where McKinley had a horse shot out from under him, and advanced to Opequon Creek, where they broke the enemy lines and pursued them farther south.[34] They followed up the victory with another at Fisher's Hill on September 22 and were engaged once more at Cedar Creek on October 19.[35] After initially falling back from the Confederate advance, McKinley helped to rally the troops and turn the tide of the battle.[35]
After Cedar Creek, the army stayed in the vicinity through election day, when McKinley cast his first presidential ballot, for the incumbent Republican, Abraham Lincoln.[35] The next day, they moved north up the valley into winter quarters near Kernstown.[35] In February 1865, Crook was captured by Confederate raiders.