Cultures began developing on Bulgarian lands during the Neolithic period, its ancient history saw the presence of the Thracians, Greeks and Romans. A unified Bulgarian state dates back to First Bulgarian Empire 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. Following years saw several conflicts with its neighbours, prompting 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.