After graduating second in his class from West Point in 1829, Lee was commissioned in the Corps of Engineers. He married (1831) Mary Anne Randolph Custis, a great-granddaughter of Martha Washington, and Arlington House, her father's residence in Virginia, was their home until the Civil War (see Arlington House, The Robert E. Lee Memorial). In the Mexican War, Lee made a brilliant record as captain of engineers with Gen. Winfield Scott's army, winning three brevets; his reconnaissances during the advance on Mexico City were important to the American success.
Lee was superintendent at West Point from 1852 to 1855, when he was made lieutenant colonel of the 2d Cavalry and sent to W Texas. He commanded that regiment from 1857 to 1861. While at Arlington House on an extended leave, he was called to lead the company of U.S. marines that captured John Brown at Harpers Ferry in Oct., 1859.