At the outbreak of the Civil War, he raised a company of cavalry and was given the rank of captain at the head of that unit. After learning that his company would not be sent to the front lines, he resigned his command and returned east, where he was appointed aide-de-camp to General George B. McClellan. McMahon remained with the Army of the Potomac throughout the war, eventually rising to the rank of brevet major general. Decades after the end of the conflict, in 1891, he was awarded the Medal of Honor for his actions at the Battle of White Oak Swamp on 30 June 1862. His official citation reads: "Under fire of the enemy, successfully destroyed a valuable train that had been abandoned and prevented it from falling into the hands of the enemy." McMahon's two older brothers were also officers in the war, both with the 164th New York Volunteer Infantry Regiment. John Eugene McMahon (1834–1863) commanded the 164th before being injured; he later died of these injuries. Middle brother James Power McMahon (1836–1864) took over the regiment and led it until his death at the Battle of Cold Harbor.
In 1866, after the end of the war, McMahon resigned his Army commission and received a Doctor of Laws degree from St. John's College, Fordham. He was New York City's corporation counsel for two years before becoming the United States minister to Paraguay, a position he held from 1868 to 1869. After returning to the U.S., he served as the Receiver of Taxes in New York from 1873 to 1885 and then worked as a U.S. Marshal for four years. During this time he became connected with the National Soldiers' Home, of which he would serve as president for several years.
He began a political career in 1890 with his election to the New York State Assembly. The next year he was elected to the New York State Senate and held that position until 1895. He was elected a judge of the Court of General Sessions in 1896 and held that position until his death. He died suddenly in 1906 at his home in Manhattan, one day after falling ill with pneumonia.