Tonkin (chữ Hán: 東京), or Bắc Kỳ (北圻), was a French protectorate encompassing modern Northern Vietnam from 1883 to 1949. Like the French protectorate of Annam, Tonkin was still nominally ruled by the Vietnamese Nguyễn dynasty. In 1886, the French separated Tonkin from the Nguyễn imperial court in Huế by establishing the office of "Viceroy" (經略衙, Kinh lược nha). However, on 26 July 1897, the position of Viceroy was abolished, officially making the French resident-superior of Tonkin both the representative of the French colonial administration and the Nguyễn dynasty court in Huế, giving him the power to appoint local mandarins. In 1887, Tonkin became a part of the Union of Indochina.
In March 1945, the emperor Bảo Đại rescinded the Patenôtre Treaty, ending the French protectorates over Annam and Tonkin, establishing the Empire of Vietnam, a Japanese-backed state. Following the surrender of Japan, ending World War II, the Việt Minh launched the August Revolution which led to the abdication of Bảo Đại and the declaration of independence of the Democratic Republic of Vietnam.