When World War II started, Zagreb was the capital of the newly formed autonomous Banovina of Croatia within the Kingdom of Yugoslavia, which remained neutral in the first years of the war. After the Invasion of Yugoslavia by Germany and Italy on 6 April 1941, German troops entered Zagreb on 10 April. On the same day, Slavko Kvaternik, a prominent member of the Ustaše movement, proclaimed the creation of the Independent State of Croatia (NDH), an Axis puppet state, with Zagreb as its capital. Ante Pavelić was proclaimed Poglavnik of NDH and Zagreb became the center of the Main Ustaša Headquarters, the Government of NDH, and other political and military institutions as well as the police and intelligence services.
Upon the establishment of NDH, the Ustaše enacted race laws and started persecuting Serbs, Jews and Roma. Thousands of locals, primarily Jews were killed in prisons and execution sites around the town, mainly in Dotršćina and Rakov Potok forests, or were taken to concentration camps and executed there.
After Germany's invasion of the Soviet Union, the Communist Party of Yugoslavia started an armed uprising against NDH. In January 1944 the 10th Zagreb Corps was formed that mainly operated in the wider Zagreb area and Northwest Croatia. The influx of refugees from war-ravaged areas of NDH nearly doubled the population of Zagreb. The Government of NDH left the city on 6 May 1945 and on 8 May Zagreb was liberated by the 45th, 28th and 39th divisions of the 2nd Army, and some units of the 1st Army of the Yugoslav Partisans. The Partisans then killed many captured soldiers and civilians accused of collaboration. In total more than 26,000 people from Zagreb lost their lives from 1941 to 1945.