Organised prehistoric cultures began developing on Bulgarian lands during the Neolithic period. Its ancient history saw the presence of the Thracians and later the Persians, Greeks and Romans. The emergence of a unified Bulgarian state dates back to the establishment of the First Bulgarian Empire in 681 AD, which dominated most of the Balkans and functioned as a cultural hub for Slavs during the Middle Ages. With the downfall of the Second Bulgarian Empire in 1396, its territories came under Ottoman rule for nearly five centuries. The Russo-Turkish War (1877–78) led to the formation of the Third Bulgarian State. The following years saw several conflicts with its neighbours, which prompted Bulgaria to align with Germany in both world wars. In 1946 it became a single-party socialist state as part of the Soviet-led Eastern Bloc. In December 1989 the ruling Communist Party allowed multi-party elections, which subsequently led to Bulgaria's transition into a democracy and a market-based economy.