<P> After pursuing the Confederate general Robert E. Lee into Maryland, Maj. Gen. George B. McClellan of the Union Army launched attacks against Lee's army, in defensive positions behind Antietam Creek . At dawn on September 17, Maj. Gen. Joseph Hooker's corps mounted a powerful assault on Lee's left flank . Attacks and counterattacks swept across Miller's Cornfield, and fighting swirled around the Dunker Church . Union assaults against the Sunken Road eventually pierced the Confederate center, but the Federal advantage was not followed up . In the afternoon, Union Maj. Gen. Ambrose Burnside's corps entered the action, capturing a stone bridge over Antietam Creek and advancing against the Confederate right . 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 . Although outnumbered two - to - one, Lee committed his entire force, while McClellan sent in less than three - quarters of his army, enabling Lee to fight the Federals to a standstill . During the night, both armies consolidated their lines . In spite of crippling casualties, Lee continued to skirmish with McClellan throughout September 18, while removing his battered army south of the Potomac River . </P> <P> Despite having superiority of numbers, McClellan's attacks failed to achieve force concentration, which allowed Lee to counter by shifting forces and moving along interior lines to meet each challenge . Therefore, despite ample reserve forces that could have been deployed to exploit localized successes, McClellan failed to destroy Lee's army . McClellan's persistent but erroneous belief that he was outnumbered contributed to his cautiousness throughout the campaign . </P> <P> McClellan had halted Lee's invasion of Maryland, but Lee was able to withdraw his army back to Virginia without interference from the cautious McClellan . McClellan's refusal to pursue Lee's army led to his removal from command by President Abraham Lincoln in November . Although the battle was tactically inconclusive, the Confederate troops had withdrawn first from the battlefield, making it a Union strategic victory . It was a sufficiently significant victory to give Lincoln the confidence to announce his Emancipation Proclamation, which discouraged the British and French governments from pursuing any potential plans to recognize the Confederacy . </P> <P> Robert E. Lee's Army of Northern Virginia--about 55,000 men--entered the state of Maryland on September 3, 1862, following their victory at Second Bull Run on August 30 . Emboldened by success, the Confederate leadership intended to take the war into enemy territory . Lee's invasion of Maryland was intended to run simultaneously with an invasion of Kentucky by the armies of Braxton Bragg and Edmund Kirby Smith . It was also necessary for logistical reasons, as northern Virginia's farms had been stripped bare of food . Based on events such as the Baltimore riots in the spring of 1861 and the fact that President Lincoln had to pass through the city in disguise en route to his inauguration, Confederate leaders assumed that Maryland would welcome the Confederate forces warmly . They sang the tune "Maryland, My Maryland!" as they marched, but by the fall of 1862 pro-Union sentiment was winning out, especially in the western parts of the state . Civilians generally hid inside their houses as Lee's army passed through their towns, or watched in cold silence, while the Army of the Potomac was cheered and encouraged . Some Confederate politicians, including President Jefferson Davis, believed that the prospect of foreign recognition would increase if the Confederacy won a military victory on Union soil; such a victory might gain recognition and financial support from the United Kingdom and France, although there is no evidence that Lee thought the Confederacy should base its military plans on this possibility . </P>

Who won the battle of antietam the north or south
find me the text answering this question