There can be confusion over the origins of Cinco de Mayo. Some think it’s a holiday celebrating Mexican independence from Spain (that’s actually September 16), or the 1910 Mexican Revolution (November 20), or that it was dreamed up to sell more beer and guacamole.

Cinco de Mayo actually marks the unlikely defeat of elite French forces by an undermanned Mexican army in the Battle of Puebla on May 5, 1862. In fact, this underdog Mexican victory may have played a part in preventing French Emperor Napoleon III from helping the Confederacy win the American Civil War.

Debts to France Lead to the Battle of Puebla

The lead-up to the battle began in 1860 when the Mexican government, bankrupt after decades of internal conflict, announced it was suspending debt payments to its European creditors for two years. Spain, the United Kingdom and France didn’t like the delay and sent over joint forces in 1861 to collect on Mexico’s debt. Spain and the UK ended up cutting deals, but French Emperor Napoleon III, a nephew of Napoleon Bonaparte, had other plans.

French Emperor Napoleon III (1808 - 1873). Illustrated London News/Getty Images

Napoleon figured if he could get his hands on Mexico, it could become the first colony in a new French stronghold in North America. Abraham Lincoln was busy fighting the Civil War, so the Americans wouldn’t stand in Napoleon’s way. Even better, with a French puppet government installed in Mexico City, Napoleon could provide guns to the Confederacy in exchange for Southern cotton, a scarce commodity in Europe thanks to Union shipping blockades.

READ MORE: 7 Things You May Not Know About Cinco de Mayo

So in early 1862, well-trained French forces under the confident command of General Charles de Lorencez, marched from the port city of Veracruz with the aim of capturing Mexico City. But on May 5, the French took a surprise beating at Puebla at the hands of Mexican General Ignacio Zaragoza and a ragtag group of enlisted and volunteer troops. The French army retreated to Veracruz to lick its wounds and wouldn’t return to take Puebla until a full year later in May of 1863.

Some contend that the year-long delay of the French invasion gave Abraham Lincoln’s generals just enough time to win decisive Union victories before Napoleon could provide upgraded artillery and munitions to the Confederacy.

“By the time the French occupy Mexico City in June of 1863, the battle of Vicksburg was already underway," says Eric Rojo, a retired U.S. Army Colonel and commander-in-chief of the Military Order of the Loyal Legion of the United States, an organization composed of descendants of Union officers in the Civil War. Rojo points out that the Battle of Gettysburg was about to begin and that Union victories were "signaling the beginning of the end" for the Confederacy. “Even if French were able to set their supply lines by mid-1863, it would have made very little difference in the outcome of the Civil War.”

Why We Celebrate Cinco de Mayo in the United States

The critical timing of the French defeat at the first Battle of Puebla was not lost on Mexican-Americans and other Latinos living in California, many who had flocked to the state during the Gold Rush. David Hayes-Bautista, director of the Center for the Study of Latino Health and Culture at the UCLA School of Medicine, was looking up birth and death records in 19th-century Spanish-speaking California newspapers when he found news reports of the very first celebrations of Cinco de Mayo as early as 1862.

Hayes Bautista says California Latinos were ardent Union supporters. When their home countries won independence from Spain, they had unilaterally abolished slavery and established citizenship for non-whites. Now living in California, a free state, they saw the pro-slavery Confederacy as an existential threat. When reports reached Los Angeles of Zaragoza’s victory against the French, Latinos made the Civil War connection immediately.

Mexican General Ignacio Zaragoza. Maogg/Getty Images

“In 1862, things weren’t going well for the Union in the Civil War, but here in Puebla was a clear-cut victory that completely threw the French timetable off,” says Hayes-Bautista. “The news reports just electrified Latinos and jolted them to a whole new level of organization and activity.”

In California and Nevada, Latinos gathered in Juntas Patrióticas (“Patriotic Assemblies”) to celebrate both the surprise victory at Puebla and what it meant for the Union cause. With 129 locations and 14,000 members in California alone, these Juntas Patrióticas started meeting monthly in 1862. There would be two or three energetic speeches extolling the heroism of Zaragoza and his outgunned troops and denouncing the pro-slavery Confederates who would take away their rights.

Over the course of the Civil War and the French occupation of Mexico City, Hayes-Bautista says, members of the Juntas Patrióticas paid dues as high as $100 a month to support the war effort on both sides of the border. On Cinco de Mayo, there would be parades in the streets carrying the Mexican and American flags and the assembled crowds would sing The Star-Spangled Banner in English and When Johnny Comes Marching Home in Spanish.

“Here in Los Angeles, the tradition of celebrating Cinco de Mayo has continued without interruption since 1862, although the original reason and the history have gotten lost,” says Hayes-Bautista, who has worked with Los Angeles dance troupes to recreate what those original Cinco de Mayo celebrations would have looked and sounded like.

We know how the Civil War ended, but how did things work out for the French in Mexico? In 1864, Napoleon installed the Archduke Ferdinand Maximilian of Austria as the Emperor of Mexico. When the Civil War ended in 1865, Lincoln made it clear that he opposed the French occupation of America’s southern neighbor. Napoleon responded by withdrawing his troops, but leaving behind Maximilian, who was captured and executed in 1867.