Under pressure from radical and politicised groups comprising mainly youths, Sukarno and Hatta, his assistant, proclaimed Indonesian independence on 17 August 1945, two days after Japan's surrender in the Pacific. The following day, the Central Indonesian National Committee declared Sukarno as the Indonesian President, and Hatta as his Vice-President.
Four years later, in December 1949, largely because of international pressure, the Dutch formally recognised Indonesian independence. Dutch efforts to re-establish complete control met much strong resistance. At the end of World War II, a power vacuum arose, due to the lack of power of the government, and the nationalists often succeeded in seizing the arms of the Japanese. A period of unrest with city guerrilla warfare, called the Bersiap period, ensued. Groups of Indonesian nationalists armed with improvised weapons, and firearms as well, attacked Allied troops who were returning to Indonesia. 3500 Europeans were killed and 20000 more went missing as a result of the attacks.
After finally returning to Java, Dutch forces quickly re-occupied the colonial capital of Batavia, now known as Jakarta, so the city of Yogyakarta in central Java became the capital of the nationalist forces. Negotiations with the nationalists led to two major truce agreements, but disputes about the implementation of the agreements, and much provocation between each other, constantly led to renewed conflict. Within four years the Dutch had recaptured most of Indonesia, but the guerrilla resistance, which was led onto Java by commander Nasution, did not give up, and continued fighting. On 27 December 1949, the Netherlands officially recognised Indonesian sovereignty under the federal structure of the United States of Indonesia. On 17 August 1950, the last of the federal states were dissolved and Sukarno proclaimed a single unitary Republic of Indonesia.