What was the first execution by firing squad in history ? Using firearms, that is.
Humayun, son of the first Mughal Emperor Babur, has been credited with the first execution by firing squad.
Over one hundred prisoners of war were captured along with around eight war elephants. However, unlike after previous battles, these prisoners were not bonded or freed; by decree from Humayun, they were shot. In His memoirs Babur recorded the incident thusly: "Ustad Ali-quli and the matchlockmen were ordered to shoot all the prisoners, by way of example; this had been Humayun's first affair, his first experience of battle; it was an excellent omen!". This is, perhaps, the earliest example of execution by firing squad.
This is before the first Battle of Panipat in April 1526.
Source: Babur (Wikispeedia)
As @SteveBird points below, the text quoted in my answer is quite ambiguous.
Wikipedia article Blowing from a gun has a section on the Mughal Empire:
Just prior to the institution of the reign of the first Mughal emperor, Babur, his son Humayun is said to have blown from guns 100 Afghan prisoners on 6 March 1526, in one incident of his father's many struggles against the Lodi dynasty.
As for the American Civil War goes, the first executions for desertion were held on August 19, 1862.
The first executions for desertion in the Army of Northern Virginia took place at Mount Pisgah Church on August 19, 1862, when three men of Brigadier General William B. Taliaferro's division and two from Brigadier General Jubal A. Early's division—all from the Shenandoah Valley or from the counties of what is now West Virginia—were shot by firing squad under orders from Lieutenant General Thomas J. "Stonewall" Jackson. As Colonel Samuel Bassett French, Jackson's aide, wrote, "the preservation of the army itself was dependent on the maintenance of discipline, and discipline could not be had if desertions were longer to go unpunished." - Military Executions during the Civil War