In the years leading up to the
Axis invasion of Yugoslavia, Rojnica served as an agent of the
Abwehr, Germany's
military intelligence service, where he received the
code name "Ante". Following the invasion and occupation of Yugoslavia, the Axis created a
puppet state known as the
Independent State of Croatia (NDH), which was placed under Ustaše rule, and which consisted of most of modern-day Croatia, all of modern-day
Bosnia and Herzegovina, and parts of modern-day
Serbia. On 18 May 1941, Italy and the NDH signed the
Treaty of Rome, whereby the latter was given control of Dubrovnik in exchange for the cession of the rest of
Dalmatia, which was integrated into the Italian state as the
Governorate of Dalmatia. On 23 May 1941, Rojnica was appointed as the commissioner () of Dubrovnik. The same day, local Ustaše launched a campaign of arrests, killings and expulsions targeting the movement's ideological opponents, such as members of the
Communist Party of Yugoslavia. Serbs and Jews were also singled out for persecution, with the latter being forced to wear a
yellow star around their arm, and to mark their properties with the
Star of David. Between 4 and 5 June 1941, the Dubrovnik Ustaše arrested the bank clerk Nikola Mašanović, the municipal treasurer Branko Hope, the merchant Branko Radonić and the journalist Jaša Miloslavić. The four men were then killed and their bodies were thrown into a river. The historian Nikola Anić argues that Rojnica was among those most responsible for these murders, given that he was Dubrovnik's most senior Ustaše official. Afterwards, Rojnica received the expropriated property of Blagoje Čorolija, the owner of a Dubrovnik
delicatessen. On 25 June, Rojnica issued a decree ordering the confiscation of all radios in Dubrovnik and restricting the movement of the city's Jews and Serbs. It read as follows: Over the course of several months, many of the Serbs and Jews who were not able to escape Dubrovnik were killed or deported to concentration camps such as
Jasenovac. He was succeeded by
Vlado Herceg, who had previously served as a
warrant officer in the
Poglavnik's Bodyguard Brigade (), which was tasked with guarding Pavelić. For the rest of the war, Rojnica took part in intelligence gathering activities. In 1943, he was promoted to the rank of
lieutenant () in the
Ustaše Militia. In the war's final months, Rojnica extorted refugees passing through Dubrovnik, forcing them to pay him exorbitant sums in return for safe passage. ==Exile==