Three railroads developed in Alexandria during the mid-19th century, a period of limited industrial expansion for the City. Alexandrians had a invested heavily in the Alexandria Canal which opened in 1843, giving the city access to the rich Cumberland coalfields via the Chesapeake & Ohio canal by 1850. Only then did they begin to invest in railroads, the newer form of transportation, to link Alexandria with the Shenandoah Valley farmland. But the Baltimore & Ohio Railroad, which reached Harpers Ferry by the mid-1830s and Cumberland by 1842, diverted much of the trade to Alexandria's rival Baltimore. Nevertheless, Alexandria's railroads contributed significantly to the city's economic prosperity prior to the Civil War by transporting passengers, mail and freight to and from western Virginia.
The Alexandria and Harpers Ferry Railroad was founded in 1847 and later reorganized to form the Alexandria, Loudoun and Hampshire Railroad which connected Alexandria with Leesburg. Incorporated in 1848, the Orange and Alexandria line reached further west to Warrenton and Gordonsville, Virginia, eventually linking with the Virginia & Tennessee Railroad at Lynchburg by 1859. The Manassas Gap Railroad was chartered to connect Strasburg and Harrisonburg in the Shenandoah valley to the Orange & Alexandria Railroad near Manassas Junction. The Alexandria and Washington Railroad was formed in 1854 to link Alexandria with the Capital City, although it was prohibited from interconnecting with other Alexandria railroads. This short line carried passengers and freight to the Virginia side of the Long Bridge (14th Street), requiring traffic to cross the Potomac River and continue into Washington by foot, stage or wagon.
All of these lines were consolidated during the Civil War when Alexandria was a vital distribution center for Union soldiers and supplies. By 1862, the Union Army had interconnected Alexandria's railroad and laid tracks across the Long Bridge for joining with the northern stretches of the Baltimore & Ohio Railroad. The Orange and Alexandria roundhouse and machinery shops became the headquarters of the Union Military Railroads.
Following the Civil War, the railroads returned to civilian ownership and helped revive Alexandria's economy, although the City never industrialized. Tracks were extended and lines merged to link Alexandria with Richmond. During the 1870s, cattle and agricultural produce, including fresh fruit and perishable dairy products, were shipped daily from the Shenandoah Valley to markets in Alexandria and Washington.
Alexandria's lines were caught up in the rivalry between the Pennsylvania Railroad and the Baltimore & Ohio Railroad during the late 19th century. The Alexandria and Washington Railroad was bought by the Pennsylvania Railroad and eventually became part of the Richmond-Washington line, which opened the Potomac Yard in 1906 as a major freight interchange later managed by the Richmond, Fredericksburg & Potomac Railroad. The original Manassas Gap and Orange & Alexandria Railroads first came under control of the Baltimore & Ohio Railroad and later were incorporated into J.P. Morgan's Southern Railroad System. Alexandria's first railroad, the Alexandria, Loudoun and Hampshire Railroad formed part of theWashington & Old Dominion Railway but finally ceased operation in 1968.