Mahan was born on September 27, 1840, at West Point, New York, to Dennis Hart Mahan (a professor at the United States Military Academy) and Mary Helena Okill Mahan (1815–1893), daughter of John Okill and Mary Jay (daughter of Sir James Jay). Mahan's middle name honors "the father of West Point", Sylvanus Thayer. Mahan attended Saint James School, an Episcopal college preparatory academy in western Maryland. He then studied at Columbia for two years, where he was a member of the Philolexian Society debating club. Against the better judgment of his father, Mahan then entered the Naval Academy, where he graduated second in his class in 1859.