St Patrick’s Day is celebrated around the world — even in Mexico.

“Every St Patrick’s Day, the first toast that I make is in honor of the San Patricios,” says Martin Paredes, a Mexican blogger based in the US. “A group of Irishmen came to the defense of Mexico, and many of them died in defense of Mexico. That has to be lauded as one of the greatest honors ever, because they were fighting for an adopted nation — and they died for an adopted nation.”

The story is pretty complex and goes back to the Mexican-American War, from 1846 to 1848.

Paredes has written extensively on the San Patricio Battalion, "a military unit that was composed mainly of Irish soldiers that were serving in the US Army when the US was invading Mexico," he explains. "These were US soldiers that left US lines and joined Mexican lines and fought for Mexico against the United States.”

Many were recent immigrants, fleeing the Great Famine in Ireland, who had joined the US Army for the promise of land and an enlistment bounty.

The reasons they deserted are complicated, Paredes says. As Irishmen and Roman Catholics, these immigrants faced a lot of discrimination in the overwhelmingly Protestant United States. “When the US actually went to war, many of them — being strong Catholics — saw what they considered an unfair invasion of a foreign country," Paredes says.

The Irish deserters formed the core of the "Battalion of Foreigners," which was later renamed the "Batallón de San Patricio." Roman Catholic deserters from Germany and other European nations also joined them, as did some foreign residents of Mexico City. There were also several African Americans who had run away from slavery in the southern United States.

A leader emerged in the person of John Riley, a Galway-born soldier who was serving in the 5th US Infantry Regiment on the eve of the war. Under Riley’s instruction, the battalion was trained and fought as an elite artillery unit, though it later converted to infantry. It fought with distinction in most of the major battles of the war until the Battle of Churubusco, on August 20, 1847. There the unit was overrun and dozens of the San Patricios were captured.

The US Army meted out harsh justice: 50 of the deserters were hung or shot. Another 35, who had deserted before the declaration of war, were flogged and branded — including Riley. While he was spared the gallows, Riley was flogged and had a "D," for deserter, seared onto his face.

The San Patricios are still seen as traitors by some Irish Americans, but Mexico has never forgotten their service. It even recently issued a postage stamp in honor of the battatlion. “There’s an annual commemoration,” Paredes says. “There are plaques all over Mexico commemorating them. There are streets named after them.”

In fact, it was the street named San Patricio in Mexico City that first led Paredes as a boy to ask about where the name came from. “We had always heard during family conversations and stuff about these Irishmen.” he says. That's why "there’s always an affinity in Mexico for anything having to do with Ireland."

Watch a performance by a Mexican pipe and drum band, La Banda de Gaitas del Batallón de San Patricio, formed and named in honor of the San Patricios.