World War II: Capitulation of German garrison in Poznań. The city is liberated by Soviet and Polish forces.

The history of Poland from 1939 to 1945 encompasses primarily the period from the invasion of Poland by Nazi Germany and the Soviet Union to the end of World War II. Following the GermanSoviet non-aggression pact, Poland was invaded by Nazi Germany on 1 September 1939 and by the Soviet Union on 17 September. The campaigns ended in early October with Germany and the Soviet Union dividing and annexing the whole of Poland. After the Axis attack on the Soviet Union in the summer of 1941, the entirety of Poland was occupied by Germany, which proceeded to advance its racial and genocidal policies across Poland. Under the two occupations, Polish citizens suffered enormous human and material losses. According to the Institute of National Remembrance estimates, about 5.6 million Polish citizens died as a result of the German occupation and about 150,000 died as a result of the Soviet occupation. The Jews were singled out by the Germans for a quick and total annihilation and about 90 percent of Polish Jews (close to three million people) were murdered as part of the Holocaust. Jews, Poles, Romani people and prisoners of many other ethnicities were killed en masse at Nazi extermination camps, such as Auschwitz, Treblinka and Sobibr. Ethnic Poles were subjected to both Nazi German and Soviet persecution. The Germans killed an estimated two million ethnic Poles. They had future plans to turn the remaining majority of Poles into slave labor and annihilate those perceived as "undesirable" as part of the wider Generalplan Ost. Ethnic cleansing and massacres of Poles and to a lesser extent Ukrainians were perpetrated in western Ukraine (prewar Polish Kresy) from 1943. The Poles were murdered by Ukrainian nationalists.

In September 1939, the Polish government officials sought refuge in Romania, but their subsequent internment there prevented the intended continuation abroad as the government of Poland. General Wadysaw Sikorski, a former prime minister, arrived in France, where a replacement Polish Government-in-Exile was soon formed. After the fall of France, the government was evacuated to Britain. The Polish armed forces had been reconstituted and fought alongside the Western Allies in France, Britain and elsewhere. A Resistance movement began organizing in Poland in 1939, soon after the invasions. Its largest military component was a part of the Polish Underground State network of organizations and activities and became known as the Home Army. The whole clandestine structure was formally directed by the Government-in-Exile through its delegation resident in Poland. There were also peasant, right-wing, leftist, Jewish and Soviet partisan organizations. Among the failed anti-German uprisings were the Warsaw Ghetto Uprising and the Warsaw Uprising. The aim of the Warsaw Uprising was to prevent domination of Poland by the Soviet Union.

In order to cooperate with the Soviet Union after Operation Barbarossa, Sikorski, an important war ally of the West, negotiated in Moscow with Joseph Stalin and they agreed to form a Polish army in the Soviet Union, intended to fight on the Eastern Front alongside the Soviets. The "Anders' Army" was instead taken to the Middle East and then to Italy. Further efforts to continue the Polish-Soviet cooperation had failed because of disagreements over the borders, the discovery of the Katyn massacre of Polish POWs perpetrated by the Soviets, and the death of General Sikorski. Afterwards, in a process seen by many Poles as a Western betrayal, the Polish Government-in-Exile gradually ceased being a recognized partner in the Allied coalition.

Stalin pursued a strategy of facilitating the formation of a Polish government independent of (and in opposition to) the exile government in London by empowering the Polish communists. Among Polish communist organizations established during the war were the Polish Workers' Party in occupied Poland and the Union of Polish Patriots in Moscow. A new Polish army was formed in the Soviet Union to fight together with the Soviets. At the same time Stalin worked on co-opting the Western Allies (the United States led by President Franklin D. Roosevelt and the United Kingdom led by Prime Minister Winston Churchill), who, in terms of practical implementations, conformed to Stalin's views on Poland's borders and future government. The fate of Poland had been determined in a series of negotiations that included the conferences in Tehran, Yalta, and Potsdam. In 1944, the Polish Government-in-Exile approved and the underground in Poland undertook unilateral political and military actions aimed at establishing an independent Polish authority, but the efforts were thwarted by the Soviets. The Polish communists founded the State National Council in 1943/44 in occupied Warsaw and the Polish Committee of National Liberation in July 1944 in Lublin, after the arrival of the Soviet army. The Soviet Union kept the eastern half of prewar Poland, granting Poland instead the greater southern portion of the eliminated German East Prussia and shifting the country west to the OderNeisse line, at the expense of Germany.

Nazi Germany, officially known as the German Reich from 1933 until 1943, and the Greater German Reich from 1943 to 1945, was the German state between 1933 and 1945, when Adolf Hitler and the Nazi Party controlled the country, transforming it into a dictatorship. Under Hitler's rule, Germany quickly became a totalitarian state where nearly all aspects of life were controlled by the government. The Third Reich, meaning "Third Realm" or "Third Empire", alluded to the Nazi claim that Nazi Germany was the successor to the earlier Holy Roman Empire (800–1806) and German Empire (1871–1918). The Third Reich, which Hitler and the Nazis referred to as the Thousand Year Reich, ended in May 1945 after just 12 years, when the Allies defeated Germany, ending World War II in Europe.

On 30 January 1933, Hitler was appointed chancellor of Germany, the head of government, by the president of the Weimar Republic, Paul von Hindenburg, the head of state. The Nazi Party then began to eliminate all political opposition and consolidate its power. Hindenburg died on 2 August 1934 and Hitler became dictator of Germany by merging the offices and powers of the chancellery and presidency. A national referendum held 19 August 1934 confirmed Hitler as sole Führer (leader) of Germany. All power was centralised in Hitler's person and his word became the highest law. The government was not a coordinated, co-operating body, but a collection of factions struggling for power and Hitler's favour. In the midst of the Great Depression, the Nazis restored economic stability and ended mass unemployment using heavy military spending and a mixed economy. Using deficit spending, the regime undertook a massive secret rearmament program, forming the Wehrmacht (armed forces), and constructed extensive public works projects, including the Autobahnen (motorways). The return to economic stability boosted the regime's popularity.

Racism, Nazi eugenics, and especially antisemitism, were central ideological features of the regime. The Germanic peoples were considered by the Nazis to be the master race, the purest branch of the Aryan race. Discrimination and the persecution of Jews and Romani people began in earnest after the seizure of power. The first concentration camps were established in March 1933. Jews and others deemed undesirable were imprisoned, and liberals, socialists, and communists were murdered, imprisoned, or exiled. Christian churches and citizens that opposed Hitler's rule were oppressed and many leaders imprisoned. Education focused on racial biology, population policy, and fitness for military service. Career and educational opportunities for women were curtailed. Recreation and tourism were organised via the Strength Through Joy program, and the 1936 Summer Olympics showcased Germany on the international stage. Propaganda Minister Joseph Goebbels made effective use of film, mass rallies, and Hitler's hypnotic oratory to influence public opinion. The government controlled artistic expression, promoting specific art forms and banning or discouraging others.

From the latter half of the 1930s, Nazi Germany made increasingly aggressive territorial demands, threatening war if these were not met. The Saarland voted by plebiscite to rejoin Germany in 1935, and in 1936 Hitler sent troops into the Rhineland, which had been de-militarized after World War I. Germany seized Austria in the Anschluss of 1938, and demanded and received the Sudetenland region of Czechoslovakia in that same year. In March 1939, the Slovak state was proclaimed and became a client state of Germany, and the German Protectorate of Bohemia and Moravia was established on the remainder of the occupied Czech Lands. Shortly after, Germany pressured Lithuania into ceding the Memel Territory. Germany signed a non-aggression pact with the Soviet Union and invaded Poland on 1 September 1939, launching World War II in Europe. By early 1941, Germany and its European allies in the Axis powers controlled much of Europe. Extended offices of the Reichskommissariat took control of Nazi-conquered areas and a German administration was established in the remainder of Poland. Germany exploited the raw materials and labour of both its occupied territories and its allies.

Genocide, mass murder, and large-scale forced labour became hallmarks of the regime. Starting in 1939, hundreds of thousands of German citizens with mental or physical disabilities were murdered in hospitals and asylums. Einsatzgruppen paramilitary death squads accompanied the German armed forces inside the occupied territories and conducted the genocide of millions of Jews and other Holocaust victims. After 1941, millions of others were imprisoned, worked to death, or murdered in Nazi concentration camps and extermination camps. This genocide is known as the Holocaust.

While the German invasion of the Soviet Union in 1941 was initially successful, the Soviet resurgence and entry of the United States into the war meant that the Wehrmacht lost the initiative on the Eastern Front in 1943 and by late 1944 had been pushed back to the pre-1939 border. Large-scale aerial bombing of Germany escalated in 1944 and the Axis powers were driven back in Eastern and Southern Europe. After the Allied invasion of France, Germany was conquered by the Soviet Union from the east and the other Allies from the west, and capitulated in May 1945. Hitler's refusal to admit defeat led to massive destruction of German infrastructure and additional war-related deaths in the closing months of the war. The victorious Allies initiated a policy of denazification and put many of the surviving Nazi leadership on trial for war crimes at the Nuremberg trials.