As soldiers celebrate their Irish heritage or at least pretend they’re Irish for St. Patrick’s Day, some distant Irish-American-Mexican history might illuminate a less-known chapter of Irish military service.

Called traitors by some and heroes by others, a group of about 265 Irish immigrants who joined the U.S. Army in the 1840s made an interestin decision as war broke out between the United States and Mexico.

Shortly after the United States annexed Texas in 1845, the two nations sent troops to their shared border. Some of those troops included immigrants from Ireland, England, Germany, France, Canada, Poland and Spain, many of these immigrants hailed from Catholic countries.

Historians have mixed theories on a single cause, but widespread abuse, mistreatment and disrespect from native-born soldiers and officers of their immigrant comrades didn’t help morale. Many in the United States disagreed with the expansionist war on its merits, including one future president, Abraham Lincoln. The Army saw its share of desertions at the time for a host of reasons.

But Mexican military leaders saw an opportunity.

Successive Mexican Army generals sent propaganda and spread messages across the Rio Grande river to U.S. troops that they should leave and join with their Catholic brothers-in-arms. Proclamations offered Mexican citizenship and land grants starting at 320 acres for privates, rising in size with the rank of any potential deserter, according to a 1950 article published in Military Affairs titled “The Battalion of Saint Patrick in the Mexican War,” by Edward S. Wallace.

“Can you fight by the side of those who put fire to your temples in Boston and Philadelphia? Come over to us! . . . May Mexicans and Irishmen, united by the sacred tie of religion and benevolence, form only one people!” one message read, according to Wallace’s article.

× Fear of missing out? Sign up for the Army Times Daily News Roundup to receive the top Army stories every afternoon. Thanks for signing up. By giving us your email, you are opting in to the Army Times Daily News Roundup.

One of those immigrant Catholics was Sgt. John Riley with Company K of the 5th U.S. Infantry, a native Irishman, possibly British Army veteran who’d resettled in the United States and later joined the Army, serving as a drill sergeant at West Point before deploying to the border.

On a Sunday morning, under the pretense of going to Mass, Riley skirted across the border and joined the ranks of the Mexican Army.

As the weeks and months progressed, a trickle of deserters also left the U.S. side. Accounts range from 175 to 265 or more soldiers who deserted and joined the other side, more than half of which were Irish immigrants, a third German and the rest primarily Catholics immigrants from other nations.

Throughout the course of the war, more than 5,000 U.S. soldiers would desert from a force of more than 40,000, though most simply disappeared into Mexico, according to sister publication Historynet.com.

The Irish defectors called themselves the St. Patrick’s Battalion, or Batallón de San Patricio in Spanish. Their Mexican comrades called them ‘San Patricios’ or sometimes “The Red Company” as many of them had red hair or a “ruddy” complexion.

The battalion’s flag was a green background with a winged angle harp, three-leaf clovers and the term “Erin Go Bragh,” or “Irish till the end of time,” in Gaelic. One of the flags was captured and on display for a time in the chapel at West Point until it was either lost or stolen, according to the 2011 book “Irish Soldiers of Mexico,” by Michael Hogan.

A Mexican commander was officially in charge of the battalion, but Riley, who’d been promoted to lieutenant, actually ran the unit. The battalion fought alongside the Mexican Army in a kind of rolling rearguard, defending key areas as the U.S. Army penetrated deeper into Mexico during the nearly two-year campaign that eventually led to the occupation of Mexico City.

They served primarily as either artillery or a mix of infantry with reinforced artillery.

Some accounts, Wallace wrote, note that in battle the San Patricios focused on killing Army officers rather than their former enlisted comrades.

With mounting losses, Mexican military leaders continued to try and pull in U.S. Army deserters, even late in the war at Puebla, in central Mexico, offering an added 200 acres to the original proclamation and cash rewards from bringing more recruits to their side.

But then, momentum was on the U.S. side and few continued to leave the ranks. Those who had deserted faced little option but to fight on.

And, apparently, they did, Wallace wrote:

“It was at Churubusco that the San Patricios made their mark in history. They, and two battalions of Mexicans, defended the strongly fortified convent of San Pablo and put up the most desperate and stubborn resistance that the Americans encountered during the entire war. Even when their ammunition was exhausted, the San Patricios three times pulled down a white flag which General Rincon, the Mexican commander, had hoisted to stop a useless massacre.”

An estimated 65 deserters were captured following that final battle for the battalion. The rest either died in earlier fighting, in that battle or escaped. The punishment for desertion during wartime was death by firing squad.

Fifty prisoners were executed just days apart, 16 on Sept. 10, 1847, four on Sept. 11, 1847 and soldiers hanged 30 men on Sept. 13, 1847, according to the 1994 book “Army of Manifest Destiny,” by James M. McCaffrey.

Though Mexican comrades pleaded for mercy for their San Patricios, only a handful who’d either been forced into service or deserted before war officially began, such as Lt. John Riley, were pardoned.

But before being freed, the men had to endure 50 lashes on their backs while tied to trees in the plaza at Churubusco and have their faces branded with a ‘D’ for deserter. A few months later, a death record in the major port city of Vera Cruz, Mexico notes that Riley passed due to drink.

But despite their travails and the war’s loss, the San Patricios are still honored every year in September in festivals in Mexico and in Ireland. The town of Clifden, Ireland, birthplace of John Riley, flies the Mexican flag every September 12 in his honor.

Bronze plaques adorn battle sites in Mexico with the names of the executed San Patricios near cannonball pockmarked building walls.