In August 1863, the regiment was combined in Centreville, Virginia, and became a part of King's Division in the XXII Corps. They later served in the Army of the Shenandoah under Philip H. Sheridan during the Valley Campaigns of 1864. Among the many actions that the 2nd Massachusetts Cavalry participated in were the battles of Fort Stevens, Opequon, Tom's Brook, and Cedar Creek. The following spring in 1865, by now under command of Colonel Caspar Crowninshield, it participated in the Siege of Petersburg. In the subsequent Appomattox Campaign it pursued elements of the retreating Army of Northern Virginia, then marched in the Grand Review of the Armies in Washington on May 23. The men were mustered out July 20, 1865, at Fairfax Court House, Virginia, before returning to California and Massachusetts in the weeks that followed.