As a result of the Soviet invasion of Poland in 1939, hundreds of thousands of Polish soldiers became prisoners of war. Many of them were executed; 22,000 Polish military personnel and civilians perished in the Katyn massacre alone.
 On September 17, 1939, the Red Army invaded the territory of Poland from the east. The invasion took place while Poland was already sustaining serious defeats in the wake of the German attack on the country that started on September 1, 1939. The Soviets moved to safeguard their claims in accordance with the Molotov–Ribbentrop Pact.
 During the Red Army's rapid advance, about 6,000–7,000 Polish soldiers died in the fighting, 230,000–450,000 were taken prisoner—230,000 immediately after the campaign and 70,000 more when the Soviets annexed the Baltic States and assumed custody of Polish troops interned there.
 The Soviets often failed to honour the terms of surrender. In some cases, they promised Polish soldiers freedom after capitulation and then arrested them when they laid down their arms. Some Polish soldiers were murdered shortly after capture, like General Józef Olszyna-Wilczyński, who was taken prisoner, interrogated and shot on September 22, during the invasion itself. On September 24, the Soviets murdered forty-two staff and patients at a Polish military hospital in the village of Grabowiec near Zamość. After a tactical Polish victory at the battle of Szack on September 28, where the combined Korpus Ochrony Pogranicza  (KOP) or Border Protection Corps forces, under General Wilhelm Orlik-Rueckemann, routed the Soviet 52nd Rifle Division, the Soviets executed all the Polish officers they captured. The Soviets also executed hundreds of defenders at Grodno, the exact number of those killed has not been established.
 Some Polish prisoners were freed or escaped, but 125,000 found themselves incarcerated in prison camps run by the NKVD. Of these, the Soviet authorities released 42,400 soldiers (mostly soldiers of Ukrainian and Belarusian ethnicity serving in the Polish army who lived in the former Polish territories now annexed by the Soviet Union) in October. The 43,000 soldiers born in West Poland, then under German control, were transferred to the Germans; in turn the Soviets received 13,575 Polish prisoners from the Germans.
 Poland and the Soviet Union never officially declared war on each other in 1939; the Soviets effectively broke off diplomatic relations when they withdrew recognition of the Polish government at the start of the invasion. The Soviets regarded captured Polish military personnel not as prisoners-of-war, but as counter-revolutionaries resisting the legal Soviet reclamation of western Ukraine and West Belarus. The USSR refused to allow Red Cross supervision of prisoners - on the grounds that it had not signed the 1929 Geneva Convention on the Treatment of PoWs and did not recognise the Hague Convention. The Soviet military handed the Polish prisoners over to the Narodnyy komissariat vnutrennikh del (People's Commissariat of Internal Affairs, better known as the NKVD or secret police), they received sentences under clauses in the Soviet penal code relating to crimes including treason and counter-revolution, and were not considered subject to the "Regulations for the Treatment of Prisoners of War" approved by the Soviet Council of Ministers.
 As early as September 19, 1939, the People's Commissar for Internal Affairs and First Rank Commissar of State Security, Lavrenty Beria, ordered the NKVD to create the Administration for Affairs of Prisoners of War and Internees to manage Polish prisoners. The NKVD took custody of Polish prisoners from the Red Army and proceeded to organize a network of reception centers and transit camps and to arrange rail transport to prisoner-of-war camps in the western USSR. The camps were located at Jukhnovo (Babynino rail station), Yuzhe (Talitsy), Kozelsk, Kozelshchyna, Oranki, Ostashkov (Stolbnyi Island on Seliger Lake near Ostashkov), Tyotkino rail station (56 mi/90 km from Putyvl), Starobielsk, Vologda (Zaenikevo rail station) and Gryazovets.
 Kozelsk and Starobielsk held mainly military officers, while Ostashkov was used mainly for Boy Scouts, gendarmes, police and prison officers.  Inmates at these camps were not exclusively military officers or members of the other groups mentioned, they also included members of the Polish intelligentsia. The approximate distribution of men throughout the camps was as follows: 
 They totalled 15,570 men.
 According to a report from 19 November 1939, the NKVD had about 40,000 Polish POWs: about 8,000-8,500 officers and warrant officers, 6,000–6,500 police officers and 25,000 soldiers and NCOs who were still being held as POWs.[failed verification] In December, a wave of arrests took into custody some Polish officers who were not yet imprisoned; Ivan Serov reported to Lavrentiy Beria on 3 December that "in all, 1,057 former officers of the Polish Army had been arrested". The 25,000 soldiers and non-commissioned officers were assigned to forced labor (road construction, heavy metallurgy).
 Once at the camps, from October 1939 to February 1940, the Poles were subjected to lengthy interrogations and constant political agitation by NKVD officers such as Vasily Zarubin. The Soviets encouraged the Poles to believe they would be released,  but the interviews were in effect a selection process to determine who would live and who would die. According to NKVD reports, the prisoners could not be induced to adopt a pro-Soviet attitude. They were declared "hardened and uncompromising enemies of Soviet authority".
 On March 5, 1940, a note to Joseph Stalin from Beria saw the members of the Soviet Politburo — Stalin, Vyacheslav Molotov, Lazar Kaganovich, Mikhail Kalinin, Kliment Voroshilov, Anastas Mikoyan and Beria — signed an order for the execution of "nationalists and counter-revolutionaries" kept at camps and prisons in western Ukraine and Belarus. This execution became known as the Katyn massacre, where 22,000 perished
 Diplomatic relations were, however, re-established in 1941 after the German invasion of the Soviet Union forced Joseph Stalin to look for allies. Thus the military agreement from August 14 and subsequent Sikorski–Mayski Agreement from August 17, 1941, resulted in Stalin agreeing to declare the Molotov–Ribbentrop Pact in relation to Poland null and void, and release tens of thousands of Polish prisoners-of-war held in Soviet camps. Pursuant to an agreement between the Polish government-in-exile and Stalin, the Soviets granted "amnesty" to many Polish citizens, from whom a military force was formed. Stalin also agreed that this military force would be subordinate to the Polish government-in-exile. This force was known as the Anders Army. From 1943 Poles were recruited into the Berling Army.
 The third group of Polish prisoners were members of Polish resistance organizations (Armia Krajowa, or 'cursed soldiers') loyal to the Polish government-in-exile and seen by the Soviets as a threat to their establishment of a power base in Poland. Relatively few were sent to the Soviet Union (although there were notable exceptions, see Trial of the Sixteen); most were transferred to the Polish communist security forces and prisons, or enlisted in the Berling Army.