Shortly before the outbreak of World War II, on August 26, 1939, Pilecki was mobilized as a cavalry-platoon commander. He was assigned to the 19th Infantry Division under Józef Kwaciszewski, part of Polish Army Prusy. His unit took part in heavy fighting against the advancing Germans during the invasion of Poland and was partially destroyed. Pilecki's platoon withdrew southeast toward Lwów (now L'viv, in Ukraine) and the Romanian bridgehead and was incorporated into the recently formed 41st Infantry Division, where he served as Division's second-in-command, under Major Jan Włodarkiewicz. During that conflict (known in Poland as the September Campaign), Pilecki and his men destroyed seven German tanks, shot down an aircraft and destroyed further two on the ground. On September 17, Soviet Union invaded eastern Poland pursuant to the Molotov-Ribbentrop Pact. Involved in more heavy fighting on two fronts, by September 22, Pilecki's division was disbanded, partially surrendering to the enemies. He returned to Warsaw with his commander, Major Włodarkiewicz.
On November 9, 1939, the two men founded the Secret Polish Army (Tajna Armia Polska, TAP), one of the first underground organizations in Poland. Pilecki became its organizational commander as TAP expanded to cover not only Warsaw but Siedlce, Radom, Lublin and other major cities of central Poland. By 1940, TAP had approximately 8,000 men (more than half of them armed), some 20 machine guns and several anti-tank rifles. Later, the organization was incorporated into the Union for Armed Struggle (Związek Walki Zbrojnej), later renamed and better known as the Home Army (Armia Krajowa). Within AK, TAP units became the core of the Wachlarz unit.[