Before dawn on September 13th, 1847, American soldiers marched twenty-nine men, most of them Irish, to a gallows near Mexico City. General Winfield Scott had ordered the execution of thirty members of the St. Patrick’s Battalion, and tasked Colonel William Harney with carrying it out. Seeing only twenty-nine men before him, Harney asked who was missing. The army surgeon explained that the thirtieth, Francis O’Connor, had had both his legs amputated the previous day. “Bring the damned son of a bitch out!” roared Harney. “My order was to hang thirty and by God I’ll do it.” The guards hauled O’Connor to the gallows, propped him up on his bloody stumps, and slung a noose around his neck. Harney then pointed to Chapultepec Castle two miles away, which had been taking American bombardment all the previous day. When the American flag rose over the castle, he explained, all thirty were to hang for desertion and defection to the enemy. Then they stood and sweated in the morning heat for four and a half hours before American forces captured the castle and the nooses pulled taut.

Branded as traitors in the States and celebrated to this day as Los San Patricios in Mexico, the St. Patrick’s Battalion was the most controversial unit of the Mexican-American War. Composed mostly of Catholic defectors from the US Army, with their ranks swelled by Mexican volunteers and escaped American slaves, the battalion was the most effective artillery unit on the Mexican side of the war, and renowned for its fearlessness and resolve.

Jon Riley, leader of the battalion, was born Seán Ó Raghallaigh in Clifden, Co. Galway, and buried Juan Reley in Veracruz. A capable leader but a grudging subordinate, Riley had risen through the ranks as an outstanding cadet instructor at West Point and a crack artillery gunner. By April 12th, 1846, he was at the Rio Grande with Zachary Taylor’s army, which was bracing for an all-but-certain war that was declared the following month. But Riley would not enter Mexico with Taylor’s army. Seething after a reprimand for disobedience, Riley requested a pass to attend Mass. He crossed the Rio Grande and reported to General Pedro de Ampudia in Matamoros.

The exact reasons for Riley’s defection are unclear, but he was hardly alone. The US army suffered a desertion rate of 8.3% during the Mexican-American War, more than double the rate in Vietnam. Many of these deserters were Catholics and recent immigrants from Germany, France, Poland, Spain, and above all Ireland, where the devastating potato blight forced a million people into emigration while a million others starved. Enlisting in the US army was one route out of crushing poverty for these economic refugees. However, nativist sentiment in the States ran high, and Protestant Americans doubted the patriotism of Catholic immigrants, whose loyalty, they surmised, lay primarily with Rome. Facing bigotry from their officers and aghast at the atrocities and the desecration of Catholic churches committed by the ill-disciplined rank-and-file, many of these immigrants felt a greater kinship with the Catholic Mexicans who they were supposed to be fighting. To help them along, the Mexican government offered good wages and land grants to defectors.

General Mariano Arista, commander of Mexico’s northern forces, commissioned Riley to raise a company of expatriate volunteers in Matamoros. Hailed as Los Colorados (“The Red Ones”) by the Mexicans on account of their ginger hair and sunburned faces, the St. Patrick’s Battalion saw its first official action at the Battle of Monterrey on September 21st, 1846. In this and subsequent engagements, the Batallón de San Patricio fought under a green silk banner with an embroidered Irish harp beneath the Mexican coat of arms.

The war did not go well for Mexico, and Riley’s men fought mostly rearguard and delaying actions to hold off the advancing American forces. The last of these came at the Battle of Churubusco on August 20th, 1847, where the remaining two hundred members of the St. Patrick’s Battalion made a desperate last stand. Expecting little mercy from the Americans, San Patricios twice shot and killed Mexican compatriots who were trying to raise the white flag of surrender. At the end of a bitter fight, 35 lay dead, another 85, including Riley, were captured, and the rest escaped to be absorbed into other battalions.

The captured San Patricios demanded to be treated as prisoners of war, but they were court-martialed as deserters. The trials were swift, the prisoners were not given legal representation, and more than half were sentenced to death by hanging even though this prolonged execution was normally reserved for spies and war criminals. Riley was spared the hangman’s noose because he had crossed into Mexico before war was declared, and the death sentence applied only to desertions during wartime. His captors, however, ensured he was punished as severely as the law allowed. Riley was submitted to fifty lashes, with one observer comparing his back to “a pounded piece of raw beef,” and then was branded in the cheek with the letter D for “deserter.” After the flogging, the heat of the brand was enough to knock Riley unconscious, but he was forcefully re-awoken: the brand had been applied backwards, so they had to sear him a second time. Riley sweated out the rest of the Mexican-American War in hard labor, but at war’s end he was released into Mexico and died two years later of too much drink.

Uncomfortably motivated by military aggression and the abstract promise of Manifest Destiny, often conducted with shocking brutality, and subject to high desertion and casualty rates, the Mexican-American War is probably the least remembered of America’s major conflicts. And yet the Treaty of Guadalupe Hidalgo that ended the war added more to American territory in a single stroke than all of America’s other wars combined. The war also fuelled western expansion and, by massively adding to America’s southern territory, brought to a high simmer tensions that would boil over a little more than a decade later into civil war. Ironically, many of the American soldiers who reviled the San Patricios for dishonoring the Stars and Stripes by fighting under an enemy banner went on to do the same themselves. The man who doomed the thirty to hang outside Chapultepec by hoisting the American flag above the castle was George Pickett, who would later lead the ill-fated Pickett’s Charge at Gettysburg—under the banner of the Confederate States of America.