In August 1861, following the outbreak of the American Civil War, Mahler assisted Philadelphia liquor merchant Henry Bohlen to recruit and organize a regiment.
At the Battle of Chancellorsville, the 75th Pennsylvania Infantry was one of the first units subjected to General "Stonewall" Jackson's flank attack, and was routed along with the rest of the 11th Corps.
During the Battle of Gettysburg, the 75th Pennsylvania Infantry was heavily engaged on the first day (July 1, 1863), in open fields north of town.
The men of this unit, having advanced a considerable distance[clarification needed] after passing through the town, held ground just east of the Carlisle Road.
The fighting intensified with the collapse of other regiments forming the Union line, and the 75th Pennsylvania Infantry was exposed to a murderous fire, that rapidly depleted the ranks.
However, as the regiment began to fall back, having been outflanked by the Confederates, Mahler received a mortal gunshot wound.