The charter of Maryland, granted in 1632 by Charles I, gave the Calvert family the territory between the Potomac River and the 40th parallel of latitude starting from the Delaware River. The boundary is a bit more complicated that that but that's essentially it.
The charter of Pennsylvania, on the other hand, granted in 1681 by Charles II, gave William Penn:
the said lands to bee bounded on the North, by the beginning of the three and fortieth degree of Northern latitude, and on the South, by a Circle drawne at twelve miles, distance from New Castle Northwards, and Westwards unto the beginning of the fortieth degree of Northerne Latitude; and then by a streight Line westwards, to the Limitt of Longitude above menconed.1
The trouble is, a circle of twelve miles radius from New Castle doesn't intersect the 40th parallel. And of course, there was the annoying fact that his father had given the same land to the Calverts. Penn later had his dominion extended to include "three lower counties" along the Delaware River, which later became the state of Delaware.
What one king giveth, another taketh away. Easy to do when you don't own it in the first place.
This bit of Stewart double-dealing naturally led to a border dispute between the aforementioned colonies. Penn had visions of a port in the Chesapeake Bay, and encouraged his supporters to settle far south of where they should have. The situation eventually led to a mini-war between 1730 and 1736, involving Thomas Cresap, the 'Maryland Monster' who raided Pennite homesteads in what is now York County. The dispute was eventually resolved and a new line agreed upon (or decreed by George III, I havent found out which yet).
Charles Mason and Jeremiah Dixon surveyed the new line between 1763 and 1767, leaving marking stones, some of which still exist, every mile.
The main, east-west, part of the line runs along 39o 43' N latitude. The western boundary of Delaware is also part of the Mason-Dixon Line. This is supposed to be a line drawn through the midpoint of the Delmarva Peninsula west of Fenwick Island, and tangent to a circle with a radius 12 miles centered on New Castle, Delaware. This was vague and inaccurate enough to cause further disputes which lasted into the 1800s.
All these geometrical arguments aside, the line, as surveyed, is the actual boundary.
1Charter of Pennsylvania, found at the Yale Law School Avalon Project, http://www.yale.edu/lawweb/avalon/states/pa01.htm