On 6 April 1941, Yugoslavia was invaded from all sides by the Axis powers, led by German forces. Stojanović was assigned as a physician to an infantry battalion based in Banja Luka. For several days after the invasion this battalion moved toward Dalmatia, before it completely disintegrated without fighting the enemy, and Stojanović returned to Prijedor. The Royal Yugoslav Army capitulated on 17 April, and the Axis powers proceeded to dismember Yugoslavia. Almost all of modern-day Croatia, all of modern-day Bosnia-Herzegovina, and parts of modern-day Serbia were combined into a puppet state called the Independent State of Croatia (, NDH). It was an "Italian-German quasi-protectorate", which was controlled by the fascist Ustaše led by Ante Pavelić. One of its policies was to eliminate the ethnic Serb population of the NDH through mass killings, expulsions and forced assimilation, and many Serbs fled from the NDH to the German-occupied territory of Serbia.