Mechanicsburg is a borough in Cumberland County, Pennsylvania, USA, eight miles west of Harrisburg. It is part of the Harrisburg–Carlisle Metropolitan Statistical Area. Mechanicsburg was settled in 1806 and incorporated as a borough on April 12, 1828. It is in a rich agricultural region known as the Cumberland Valley, a broad zone between South Mountain and the ridge-and-valley Appalachians. In 1900, 3,841 people lived here; in 1910, 4,469, which increased to 5,709 in 1940. As of the 2000 census, the borough population was 9,042. Mechanicsburg is home of Jubilee Day, the largest and longest-running one-day street fair on the east coast. It is estimated as many as 60,000 people attend Jubilee Day annually. The borough is home to Mechanicsburg Area Senior High School and just outside the borough is Cumberland Valley High School. According to the United States Census Bureau, the Mechanicsburg has a total area of 2.6 square miles, all of it land and is located at 40° 12' 44"N 77° 00' 22"W.

Named for a settlement of mechanics who made and repaired Conestoga wagons in the early 1800s, Mechanicsburg's continued growth was also attributed to the Cumberland Valley Railroad (CVRR). Completing its line in 1837, Mechanicsburg was designated as a water station where workers could restock the locomotive's wood and pump water. The train became the town's link to the world of business and industry. Grain and feed companies, lumber yards and numerous factories were purposely built alongside the railroad tracks. Archives show that, at one time, there were twenty-five trains chugging through the town daily carrying travelers, coal, feathers, fruit, ice, mail and newspapers. During the American Civil War, the railroad was an invaluable method of transporting troops and supplies. Today, approximately six trains travel through Mechanicsburg each day, which has recently increased due to new operations on the local sub-line owned by Norfolk Southern. Another part of Mechanicsburg's growth occurred when the Naval Support Activity was built on 840 acres of land in Hampden Township, Pennsylvania. Although automotive technology changed the town forever, today's residents cannot dismiss the vital role the railroad played in its development.

Present-day Mechanicsburg is centered on 100 acres that Leonard Fisher purchased from Joseph Heynes tract (No. 1442 of an original grant of 267 acres from William Penn). Before becoming incorporated on April 12, 1828, the town went by several different names. First, Drytown, because of the extreme scarcity of water during the winter and summer. It was also known as Pinchgut, a German name used as a sign of amusement given to a small village of only a few people. Some also referred to the town as Staufferstown, in honor of Henry Stauffer, the owner of much of the land in the center of town. Briefly, referred to as Creekville during the Colonial Era, Mechanicsburg is home to many historic markers, such as Irving Female College (named for Washington Irving, a trustee), the first women's college in Pennsylvania to grant degrees in arts and sciences.

On June 28, 1863, Confederate troops led by Brig. Gen. Albert G. Jenkins raided Mechanicsburg, and two days later, met with Union forces in the Skirmish of Sporting Hill, just east of town. It is known as the northern most engagement of the Civil War. Following the Skirmish of Sporting Hill, the Confederate forces retreated south into the little town of Gettysburg where the Battle of Gettysburg would be fought.

The oldest building in Mechanicsburg is the Frankeberger Tavern. One of Mechanicsburg's first residents was George Frankeberger, who in 1801 applied for a license to open his newly built log home for the "convenience" of travelers. In exchange for a small fee, Mr. Frankeberger offered cattle drivers a warm meal and a place to sleep. This proved to be rather lucrative, as many people were making the two day trek between Harrisburg (the state capital) and Carlisle (Cumberland County's county seat). A local legend tells of a man who came into a good deal of money having just sold some cattle in Harrisburg. After boasting about it in front of many of the other travelers in the tavern, he retired for the night. Another man, having heard about the gold he was carrying, followed him to his room, cut off his head, and stole his money. Legend has it that a headless ghost can sometimes be seen sitting atop the roof of Frankeberger Tavern, looking out over the roofs of town, searching for the man who stole his gold.