The history of the Khitans dates back to the 4th century. The Khitan people dominated much of northern China, Manchuria and the Mongolian Plateau. They subsequently established the Liao dynasty and the Western Liao dynasty. Originally from Xianbei origins, the Khitans were part of the Kumo Xi tribe until 388 when the Kumo Xi–Khitan tribal grouping was defeated by the newly-established Northern Wei dynasty. This allowed the Khitans to reorganize and consolidate their own tribal identity which led to the beginning of Khitan written history.