Due to its geography as Vietnam's gateway to China, Lạng Sơn and its ancient citadel have been in the path of many invasions, and were the site of three French defeats during the colonial era. Occupied by Qing forces during the military buildup that preceded the Sino-French War, the city was occupied by France after the two-week Lạng Sơn Campaign in February 1885. However, the brigade there conducted a hasty retreat after a failed attack at the Battle of Bang Bo into China; the "retreat from Lạng Sơn" became the most controversial aspect of the war and led to the fall of Jules Ferry's ministry. Outnumbered French colonial forces clashed with the Japanese 5th Division in the Battle of Lạng Sơn during the Japanese Vietnam Expedition on 22 September 1940. The French were again compelled to retreat hastily. In 1945 it was again the scene of heavy fighting during the Japanese coup d'état in French Indochina.