Hungarian prehistory (Hungarian: magyar őstörténet) spans the period of history of the Hungarian people, or Magyars, which started with the separation of the Hungarian language from other Finno-Ugric or Ugric languages around 800 BC, and ended with the Hungarian conquest of the Carpathian Basin around 895 AD. Based on the earliest records of the Magyars in Byzantine, Western European, and Hungarian chronicles, scholars considered them for centuries to have been the descendants of the ancient Scythians and Huns. This historiographical tradition disappeared from mainstream history after the realization of similarities between the Hungarian language and the Uralic languages in the late 18th century. Thereafter, linguistics became the principal source of the study of the Hungarians' ethnogenesis. In addition, chronicles written between the 9th and 15th centuries, the results of archaeological research and folklore analogies provide information on the Magyars' early history.
Study of pollen in fossils based on cognate words for certain trees – including larch and elm – in the daughter languages suggests the speakers of the Proto-Uralic language lived in the wider region of the Ural Mountains, which were inhabited by scattered groups of Neolithic hunter-gatherers in the 4th millennium BC. They spread over vast territories, which caused the development of a separate Proto-Finno-Ugric language by the end of the millennium. Linguistic studies and archaeological research evidence that those who spoke this language lived in pit-houses and used decorated clay vessels. The expansion of marshlands after around 2600 BC caused new migrations. No scholarly consensus on the Urheimat, or original homeland, of the Ugric peoples exists: they lived either in the region of the Tobol River or along the Kama River and the upper courses of the Volga River around 2000 BC. They lived in settled communities, cultivated millet, wheat, and other crops, and bred animals – especially horses, cattle, and pigs. Loan words connected to animal husbandry from Proto-Iranian show that they had close contacts with their neighbors. The southernmost Ugric groups adopted a nomadic way of life by around 1000 BC, because of the northward expansion of the steppes.