In Maryland, US 340 follows the corridor of the old road from Frederick to Harpers Ferry, part of which was organized as the Frederick and Jefferson Turnpike between the two towns. This highway became one of the original state roads marked for improvement by the Maryland State Roads Commission in 1909. The commission purchased the right-of-way of the turnpike in 1911 and resurfaced the Frederick–Jefferson highway with a 14-foot (4.3 m) wide macadam surface in 1915. The segments from Jefferson to Petersville and from Petersville to Knoxville were placed under construction in 1911 and completed as a 14-foot (4.3 m) macadam road in 1912. The highway from Knoxville to the Potomac River opposite Harpers Ferry was completed as a concrete road in 1919. The Frederick–Knoxville highway was widened to 17-foot (5.2 m) in width around 1926 and became part of US 340 in 1927. US 340 was widened again, this time to 20 feet (6.1 m) between Frederick and Knoxville, by 1934.
US 340 was widened and resurfaced with bituminous concrete from Knoxville to the approach to new bridge at Sandy Hook in 1948. In conjunction with the construction of the Frederick Freeway, US 340's cloverleaf interchange with US 40 was built in 1954 and 1955. Jefferson Street in Frederick was widened in 1956. When US 40 was moved from Patrick Street to the Frederick Freeway in 1959, US 340's eastern terminus was moved from Patrick Street west to the new interchange. Construction on the US 340 freeway began when the highway's bridge across Catoctin Creek was built in 1961. This bridge came into use in 1964 when the freeway segment between the MD 180 interchange east of Petersville and the ramp from MD 180 west of Jefferson was opened, replacing the curvaceous old alignment at Catoctin Creek. The present alignment of US 340 opened as a four-lane divided highway from the Valley Road / Keep Tryst Road intersection in Sandy Hook east to Weverton also opened that year. The portion of the freeway between Weverton and MD 180 east of Petersville was under construction in 1964 and completed in 1965. MD 180 was assigned to old US 340 from Sandy Hook to west of Jefferson in 1965.
Construction on the US 340 freeway east toward Frederick began in 1966. The freeway east to the current Point of Rocks – Jefferson segment of US 15 was completed in 1967; however, the US 15 interchange would not become operational until the new US 15 was completed and the two U.S. highways became concurrent in 1970. US 340's interchanges with I-70 and MD 180 were completed in 1968 and the portion of the freeway from the US 15 interchange east to MD 180 opened in 1969. At that time, MD 180 was extended east over the old Jefferson–Frederick section of US 340. US 340's interchanges with MD 67 in Weverton and Mt. Zion Road near Frederick opened in 1971 and 1972, respectively. Several ramps were added to improve access between US 340 and I-70 in 1997, including a pair of ramps from eastbound I-70 to US 340 and the connection from northbound US 340 to westbound I-70 at US 340's northern terminus. The interchange at US 340's northern terminus was converted from a cloverleaf interchange to a partial cloverleaf interchange with traffic signals in 2004.
US 340 originally followed Sandy Hook Road south and west from what is now Keep Tryst Road in Sandy Hook and paralleled the Potomac River west to Maryland Heights directly across the river from downtown Harpers Ferry. There, the U.S. highway crossed the river on a converted railroad bridge immediately upstream from the confluence of the Potomac and Shenandoah rivers and downstream from the two railroad bridges—one for CSX's Cumberland Subdivision on the north and the other for the Shenandoah Subdivision—that presently cross the river at the site. After the highway bridge was destroyed in the March 1936 flood, a wooden floor was placed on the Shenandoah Subdivision bridge for that bridge to temporarily serve both rail and automobile traffic. Later in 1936, Maryland and West Virginia acquired the right-of-way of the destroyed toll bridge owned by the Harpers Ferry and Potomac Bridge Company by eminent domain with an aim to build a new bridge at the site.