Lee entered West Point in 1825. When he graduated (second in his class of forty six) in 1829 he had not only attained the top academic record but was the first cadet (and so far the only) to graduate the Academy without a single demerit. He was commissioned as second lieutenant in the engineers.
Lee served for seventeen months at Fort Pulaski on Cockspur Island, Georgia. In 1831, he was transferred to Fort Monroe, Virginia, as assistant engineer. While he was stationed there, he married Mary Anna Randolph Custis, the great-granddaughter of Martha Washington. They lived in the Custis mansion, located on the banks of the Potomac River in Arlington, just across from Washington, D.C. They eventually had three sons and four daughters.
Lee served as an assistant in the chief engineer's office in Washington from 1834 to 1837, but spent the summer of 1835 helping to lay out the state line between Ohio and Michigan. In 1837, he got his first important command. As a first lieutenant of engineers, he supervised the engineering work for St. Louis harbour and for the upper Mississippi and Missouri rivers. His work there earned him a promotion to captain. In 1841, he was transferred to Fort Hamilton in New York harbour, where he took charge of building fortifications.
Lee distinguished himself in the Mexican War 1846-1848. He was one of Winfield Scott's chief aides in the march from Vera Cruz to Mexico City. He was instrumental in several American victories by finding a route to attack the Mexicans which was not defended because the terrain was thought to be impassable.
He was promoted to Major after the battle of Cerro Gordo in April, 1847. He also fought at Contreras, Cherubusco and Chapultepec, and was wounded at the latter. By the end of the war he had been promoted to Lieutenant-Colonel.
After the Mexican War, he spent three years at Fort Carrol in Baltimore harbor then became the superintendent of West Point in 1852. During his three years at West Point, he improved the buildings, the courses, and spent a lot of time with the cadets.
These were not happy years for Lee as he did not like to be away from his family for long periods of time, especially as his wife was becoming increasingly ill. Lee came home to see her as often as he could.
He happened to be in Washington at the time of John Brown's raid on Harpers Ferry, Virginia (now West Virginia) in 1859, and was sent there to arrest Brown and to restore order. He did this very quickly and then returned to his regiment in Texas. When Texas seceded from the Union in 1861, Lee was called to Washington, DC to wait for further orders.
On April 18, 1861, on the eve of the American Civil War, President Abraham Lincoln, through Secretary Francis Blair, offered him command of the United States (Union) Army. There was little doubt as to Lee's sentiments. He was opposed to secession. However his loyalty to his native Virginia led him to join the Confederacy. At the outbreak of war he was appointed to command all of Virginia's forces, and then as one of the first five full generals of Confederate forces. After commanding Confederate forces in western Virginia, and then in charge of coastal defenses along the Carolina seaboards, he became military adviser to Jefferson Davis, president of the Confederacy, whom he knew from West Point.
Following the wounding of Gen. Joseph E. Johnston at the battle of Seven Pines, on June 1, 1862, he received the command of the Army of Northern Virginia and soon launched a series of attacks, the Seven Days Campaign against General George B. McClellan's Union forces threatening Richmond, Virginia, the Confederate capital. After McClellan's retreat, Lee defeated another Union army in the battle of Second Manassas. He then invaded Maryland, but retreated after evading destruction by McClellan's superior force at Battle of Antietam. Disappointed by McClellan's failure to destroy Lee's army, Lincoln named Ambrose Burnside as commander of the Army of the Potomac. Burnside ordered an attack across the Rappahannock river at Fredericksburg. Delays in getting bridges built across the river allowed Lee's army ample time to organize strong defenses, and the attack on December 12, 1862 was a disaster for the Union. Lincoln then named Joseph Hooker commander of the Army of the Potomac. Hooker's advance to attack Lee in May 1863 near Chancellorsville, Virginia was defeated by Lee and Stonewall Jackson's daring plan to divide the army and attack Hooker's flank. It was an enormous victory over a larger force, but came at a great cost as Jackson was fatally wounded.
Lee then proceeded to invade the North again, hoping for a Southern victory that would compel the North to grant Confederate independence. But his attempts to attack the Union forces at Gettysburg, Pennsylvania failed. Lee was compelled to retreat again and, as after Antietam, was not vigorously pursued. Following his defeat at Gettysburg, Lee sent a letter of resignation to Confederate President Jefferson Davis on August 8, 1863 but Davis refused Lee's request upon receipt.
In 1864, the new Union supreme commander Ulysses Grant sought to destroy Lee's army and capture Richmond. Lee and his men stopped each advance, but Grant had courage and enough men to keep trying again a bit further to the east. These battles included the Wilderness, Spottsylvania Courthouse, and Cold Harbor. After stopping a Union attempt to capture Petersburg, Virginia, a vital railroad link supplying Richmond, Lee's men built elaborate trenches and stayed on the same lines from June 1864 until April 1865.
On January 31, 1865, Lee was promoted to be general-in-chief of Confederate forces. In early 1865, he urged adoption of a scheme to allow slaves to join the Confederate army in exchange for their freedom. The scheme never came to fruition in the short time the Confederacy had left.
As the Confederate army was worn down by months of battle, a Union attempt to capture Petersburg on April 2, 1865 succeeded. Lee abandoned the defense of Richmond and sought to join General Joseph Johnston's army in North Carolina. His forces were surrounded by the Union army and he surrendered to General Grant on April 9, 1865, at Appomattox Courthouse, Virginia.
Following the war, Lee applied for, but was never granted, the official postwar amnesty. His wife's family home the Custis-Lee Mansion, where they had lived before the Civil War, had been confiscated by Union forces and now is part of Arlington National Cemetery. His example of applying for amnesty was an encouragement to many other former Confederates to accept being citizens of the United States once again.
He served as president of Washington College (now Washington and Lee University) in Lexington, Virginia from October 2, 1865. Under his leadership, Washington College became one of the first American colleges to offer courses in business, journalism and Spanish. He died in Lexington on October 12, 1870.
In 1975, Lee's USA citizenship was restored posthumously by an act of the U.S. Congress.