France assumed sovereignty over Annam and Tonkin after the Franco-Chinese War (1884-1885). Indochina was formed in October 1887 from Annam, Tonkin, Cochin China, and the Khmer Republic; Laos was added in 1893. The federation lasted until 1954. The capital of Indochina was Hanoi. There was a series of puppet Emperors.
In September 1940, during World War 2, Vichy France (which had just submitted to Nazi Germany) granted Japan's demands for military access to Tonkin. Immediately this allowed Japan better access to China in the Sino-Japanese War, against the forces of Chiang Kai-shek. But it was also part of Japan's strategy of domination of the Pacific Ocean, helped greatly by the success of its ally Germany in defeating Pacific powers the Netherlands (see Dutch East Indies) and France. The Japanese kept the French bureaucracy and leadership in place to run Indochina.
On March 9, 1945 with France firmly under Allied domination, Germany in retreat, and the USA ascendant in the Pacific, Japan decided to take complete control of Indochina. The Japanese kept power until the news of their government's surrender came though in August, after the atomic bombs were dropped on Hiroshima and Nagasaki.
After the war, France attempted to reassert itself in the region, but came into conflict with the Viet Minh, an organization of Communist Vietnamese nationalistss under French-educated Ho Chi Minh. During WW2, the USA had supported the Viet Minh in resistance against the Japanese; the group was in control of the country apart from the cities since the French gave way in March 1945. After persuading Emperor Bao Dai to abdicate in his favour, on September 2, 1945 Ho -- as president -- declared independence for the Democratic Republic of Vietnam. But before the end of September, a force of British, French and Indians, who also pressed captured Japanese into service, restored French control. Bitter fighting ensued. In 1950 Ho again declared an independent Democratic Republic of Vietnam, which was recognized by the fellow Communist governments of China and the Soviet Union.
Fighting lasted until March 1954, when the Viet Minh won the decisive victory against French forces at the gruelling Battle of Dien Bien Phu. This led to the partition of Vietnam into North, under Viet Minh control, and South, called the Republic of Vietnam, which had the support of the USA, Great Britain, and France. The events of 1954 also marked the end of French involvement in the region, and the beginnings of serious US commitment to South Vietnam which was to lead to the Vietnam War.
The partition was agreed to at the Geneva Conference, where the United States of America, The Soviet Union, Great Britain, Grance and the People's Republic of China also settled a number of outstanding disputes relating to the Korean War. It was at this conference that France relinquished any claim to territory in the Indochinese peninsula.
Laos and Cambodia also became independent in 1954, but were both drawn into the Vietnam War.