King Prithvi Narayan Shah of Gorkha in 1786 had invaded the Kathmandu Valley and unified Nepal. Before the unification, Nepal was ruled by various Kirats, Lichchavis, Thakuris and Mallas. The history mentioned that Kirats ruled Nepal during the 7th century BC. Though much was not known about Kirats,the Lichchavi dynasty followed the Kirats which lasted from the 2nd to 9th century AD. Nepal was ruled by the Thakuris who were followed by the Mallas for two centuries after The Lichchavis. Nepal was divided into many principalities and small kingdoms in the fifth centuries of Malla rule.