Mechanicsburg is a borough in Cumberland County, Pennsylvania, United States, 8 miles (13 km) west of Harrisburg. It is part of the Harrisburg–Carlisle Metropolitan Statistical Area. As of the 2010 census it had a population of 8,981.
Mechanicsburg is located in eastern Cumberland County at 40°12′44″N 77°00′22″W. It is in a rich agricultural region known as the Cumberland Valley, a broad zone between South Mountain and the Ridge-and-Valley Appalachians.
Mechanicsburg is bordered by Silver Spring Township to the northwest, Monroe Township to the southwest, Upper Allen Township to the south, Lower Allen Township to the east, and Hampden Township to the northeast. Pennsylvania Route 641 (Trindle Road) is the main east-west street through the borough, leading east 4 miles (6 km) to Camp Hill and west 10 miles (16 km) to Carlisle, the county seat. Pennsylvania Route 114 leads north out of town on York Street and south on Market Street. Interstate 76, the Pennsylvania Turnpike, passes just south of Mechanicsburg, with access to the southeast of town via Exit 236 (U.S. Route 15).
According to the United States Census Bureau, the borough has a total area of 2.41 square miles (6.25 km2), of which 1.1 acres (4,478 m2), or 0.07%, is water.
In 1900, 3,841 people lived here; in 1910, the population was 4,469, which increased to 5,709 in 1940. As of the 2010 census, the borough population was 8,981.