During World War II, Thailand was an ally of the Empire of Japan. In that capacity, it gained some territories that were incorporated in Thailand in exchange for freedom for the Japanese government to establish military bases in these territories as well as in the rest of Thailand. The territories gained by Thailand were taken from French Indochina during a brief war with France in late 1940 and early 1941 and from British Malaya during the Japanese attack in December 1941. On 25 January 1942, the Thai government declared war on the United States and the British Empire. The Northern Army was sent to assist in the invasion of British Burma and part of that area was annexed.