The first stages of warfare were initiated in October 1945 when, in accordance with the terms of their surrender, the Japanese tried to re-establish the authority they had relinquished to Indonesians in the towns and cities. Japanese military police killed Republican "pemuda" in Pekalongan (Central Java) on 3 October, and Japanese troops drove Republican "pemuda" out of Bandung in West Java and handed the city to the British, but the fiercest fighting involving the Japanese was in Semarang. On 14 October, British forces began to occupy the city. Retreating Republican forces retaliated by killing between 130 and 300 Japanese prisoners they were holding. Five hundred Japanese and two thousand Indonesians had been killed and the Japanese had almost captured the city six days later when British forces arrived. The Allies repatriated the remaining Japanese troops and civilians to Japan, although about 1,000 elected to remain behind and later assisted Republican forces in fighting for independence.