The 1839 Massachusetts gubernatorial election was the closest governor's race in United States history. Marcus Morton was certified winner, receiving exactly half the votes cast. Under Massachusetts law at the time, a majority of the votes cast was required to win. Despite the presence of some irregularities, incumbent Whig Governor Edward Everett refused to contest the results once a legislative committee dominated by his party accepted a report giving Morton 51,034 votes out of 102,066 cast.
In the 19th century Massachusetts held annual elections for its statewide elective offices. From 1825 to 1838 a succession of National Republican and then Whig politicians won the governor's seat, at first by wide margins, and only later in the 1830s by narrower margins. The principal opponent of the Whigs was Democratic candidate Marcus Morton, who ran for governor each year from 1828 to 1843. The Democratic Party in the state was not particularly powerful, and third parties such as the Anti-Masonic Party and the Liberty Party generally took more votes from Democratic candidates than they did from Whigs.
The Whigs were seen as representatives of the monied interests in the state: merchants, bankers, and industrialists. They were derided by their opponents as "aristocratic" and condescending to the common folk. The Democratic support base consisted of rural voters, laborers, and wealthier interests that were supportive of the policies of President Andrew Jackson.
Abolitionism became a significant political force in the mid-1830s in Massachusetts, even though both Whig and Democratic politicians sought to avoid the issue in pursuit of other political objectives. Abolitionist activists attempted to force attention on the issue, demanding that candidates for office answer questionnaires on the subject. Marcus Morton was known to be personally opposed to slavery, but he did not often let the matter affect his politics, and expressed concern over abolitionist tactics. His Whig opponent since 1835 was Edward Everett, who once gave a speech expressing sympathy for the property rights of slaveholders and was not seen as sympathetic to the abolitionist cause. In the elections of 1837 and 1838 abolitionist support increased Morton's vote counts, but he was never able to achieve the majority of votes needed to win election in the state.
In 1839, an issue unrelated to slavery came up that finally gave Morton a victory. The Whig legislature had passed a bill promoted by temperance activists that banned the sale of liquor in quantities less than 15 US gallons (57 l); this effectively outlawed service over a bar.
The election was held on Monday, November 11, 1839. Early returns gave Everett the lead, although his showing in Boston, a Whig stronghold, was particularly weak. On November 14, the accumulated returns indicated that Everett led by 100 votes, with 250 communities still to report. The next day, Morton was reported to lead by just two votes. A number of Whig officials (notably including Secretary of State H. A. S. Dearborn), failed to vote, prompting Everett to observe, despite their protestations that they supported his candidacy, "a better mode of showing [their support] would have been to vote". A number of irregularities were identified during the initial count. The ballots from Easton had not been properly sealed by the town clerk, and the Winchendon return was dated 1809 instead of 1839. These votes were counted.
The vote was so close that no result was certified until the legislature met. On January 1, 1840, the new Whig-dominated legislature met, and sent the election issue to a joint committee. One ballot for Morton contained the scrawl "Maccus Mattoon"; despite efforts by Whig partisans to deny the writer intended to vote for Morton, no person with that name was found anywhere in the state. A more serious issue was raise with respect to the returns from Westfield: the town clerk there had not properly sworn to the accuracy of the result, and Everett was of the opinion that these results should be rejected.
The legislative joint committee issued its report on January 13, 1840. It stated that a total of 102,066 votes had been cast (including all of the votes affected by the irregularities, which were accepted), and that therefore 51,034 votes were required to win. Morton was found to have received exactly that number, while Everett received 50,725, and a scattering of candidates received votes on the remaining 307 ballots cast.
Despite pressure from partisans to contest this result, Everett refused. He recorded in his journal, "Principle is no longer sufficiently powerful even in Massachusetts to warrant an adherence to the strict provisions of the Constitution on a question of this kind." Everett also refused his friend and Whig colleague Robert Charles Winthrop to publish a partisan tribute to him, noting "I am willing to let the election go." Morton was sworn in as governor on January 18, 1840.
Although the Democrat won the governor's seat, the legislature remained firmly Whig, and refused to enact Morton's reformist agenda (in particular, it did not vote to repeal the fifteen-gallon law). The Whigs regrouped, and in 1840 Morton was defeated by John Davis. Morton won another single term in 1842, in a hotly contested election that was decided by the state legislature.