In the decade before WWII, Mexico was chaotic and unstable. The Mexican Revolution (1910-1920) which caused widespread destruction and claimed hundreds of thousands of lives was followed by several violent uprisings against the new government (Cristero War from 1926-1929). Then, during the Great Depression, the Mexican economy suffered badly.
In 1934 the reformer Lázaro Cárdenas del Rio took power and helped Mexico move toward a more stable, productive nation. Cárdenas kept Mexico neutral as conflict grew in Europe, even though Nazi and American agents vied for an alliance with Mexico. Although great outcry arose when Cárdenas nationalized Mexico’s vast oil reserves, with war clouds on the horizon, the U.S. Government and private interests were forced to accept it.
At the start of the war in Europe, the Mexican Communist Party supported Germany while the 1939 German-Soviet Non-Agression Pact was still in place. However, once Germany invaded the USSR, Mexican Communists switched allegiance to the Allies. At the other end of the political spectrum, a group of extremely conservative Catholics formed the Unión Nacional Sinarquista in opposition to Cardenas and supportive of the Axis powers.
Additionally, historical grievances with the USA ( loss of Texas and American southwest territories, U.S. intervention during the revolution and multiple incursions into Mexican territory) caused great resentment and distrust of the USA. Many Mexicans were ambivalent as to whether they should join the Axis cause against their historical U.S. antagonist, or remain neutral (thereby not providing an excuse for another U.S. invasion).
In 1940, Mexico elected the conservative (PRI- Revolutionary Party) presidential candidate Manuel Ávila Camacho who pursued a course of detente with the U.S. Although there was much initial dissent in Mexico with this policy, once Germany attacked the USSR (and Mexican Communists switched allegiance to the Allies) support for Ávila’s policies grew. After the attack on Pearl Harbor, Mexico was one of the first countries to pledge support and aid, and they severed all diplomatic ties with the Axis powers.
US capital began to flow into Mexico for industry supporting military needs. The U.S. bought Mexican oil and sent technicians to enhance Mexican mining of metals needed for wartime production (e.g., mercury, zinc,copper). Mexican armed forces were supplied with US weapons and training.
When German U-boats sank two Mexican tankers, the Potrero del Llano on 14 May and Faja de Oro on 21 May , sixteen Mexicans died. On May 21, 1942 Mexico declared war on Germany.