At a crucial moment , Maj. Gen. A.P. Hill 's division arrived from Harpers Ferry and launched a surprise counterattack , driving back Burnside and ending the battle . At a crucial moment , Confederate Maj. Gen. A.P. Hill 's division arrived from Harpers Ferry and launched a surprise counterattack , driving back Burnside and ending the battle .