During the campaign in Sicily, King Victor Emmanuel III of Italy arrested Prime Minister Benito Mussolini and replaced him with Pietro Badoglio, who secretly negotiated a surrender with the Allies. Germany responded by shifting several divisions to Italy, occupying Rome, and establishing a puppet state, the Italian Social Republic. The Allied invasion of mainland Italy began in September 1943. In the aftermath of Italy's surrender, the Allies faced unexpectedly strong resistance from German forces under Field Marshal Albert Kesselring, who nearly defeated Operation Avalanche, the Allied landing near the port of Salerno. With 24 German divisions defending the country's rugged terrain, Italy quickly became a secondary theater in the war.