The history of Vietnam begins around 2,700 years ago. Successive dynasties based in China ruled Vietnam directly for most of the period from 207 BC until 938 when Vietnam regained its independence. Vietnam remained a tributary state to its larger neighbor China for much of its history but repelled invasions by the Chinese as well as three invasions by the Mongols between 1255 and 1285. Emperor Trần Nhân Tông later diplomatically submitted Vietnam to a tributary of the Yuan to avoid further conflicts. The independent period temporarily ended in the middle to late 19th century, when the country was colonized by France (see French Indochina). During World War II, Imperial Japan expelled the French to occupy Vietnam, though they retained French administrators during their occupation. After the war, France attempted to re-establish its colonial rule but ultimately failed in the First Indochina War. The Geneva Accords partitioned the country in two with a promise of democratic election to reunite the country.