Gen. George A. Custer's brigade of the 3rd Division. A lengthy mounted battle, including hand-to-hand combat, ensued. Both sides claimed victory. On July 16, during the Battle of Williamsport in the Army of Northern Virginia's long Retreat from Gettysburg, Gregg's division clashed with the cavalry brigades of Brig. Gens. Fitzhugh Lee and John R. Chambliss near Shepherdstown. In October 1863, Lee attempted to flank the Union army near Warrenton, Virginia. Gregg's division delayed Lee until the II Corps under Maj. Gen. Gouverneur K. Warren arrived to block the movement. Gregg caused an incident when, after this engagement, he did not get adequate mention in Maj. Gen. George G. Meade's after action report and demanded a court of inquiry to correct the record. Gregg commanded the Cavalry Corps of the Army of the Potomac in early 1864 until the arrival of Maj. Gen. Philip Sheridan, who commanded the cavalry of the forces of Lt. Gen. Ulysses S. Grant in the Overland Campaign. The most important use of Gregg's cavalry during this campaign was to screen Union movements southward, battle to battle, but a significant raid was staged that culminated in the Battle of Yellow Tavern, where J.E.B. Stuart was mortally wounded, dealing the Confederacy a hard blow. Gregg's division also was heavily engaged at the Battle of Haw's Shop, where it fought Wade Hampton's troopers west of Hanovertown, Virginia. Hampton had superior numbers, but Gregg's troopers had the Spencer repeating rifle. Finally, Custer's brigade attacked through difficult terrain, ousting Hampton's men from their position. Concluding the raid culminating in the Battle of Trevilian Station, Sheridan's cavalry retreated toward Bermuda Hundred. Gregg's division covered the retreat, especially in the Battle of Saint Mary's Church. Gregg's division survived a strong attack directed by Wade Hampton, but it lost several prisoners, including Colonel Pennock Huey. Gregg commanded the cavalry division that remained near Petersburg while Sheridan was engaged in the Shenandoah Valley Campaign against Jubal Early. In his role as cavalry commander, Gregg screened various union movements in the Siege of Petersburg. Gregg's division was particularly engaged at the Second Battle of Deep Bottom, the Second Battle of Ream's Station, and the Battle of Peebles' Farm. Near the end of his service, he was promoted to the brevet rank of major general. Later life David Gregg resigned his army commission, in a letter dated January 25, 1865: Gregg's real reasons for resigning before the