The southern part of the county fell under Ottoman rule, while the northern part remained part of the Kingdom of Hungary. On 5 September 1619, the prince of Transylvania, Gabriel Bethlen captured Košice in Abauj with the assistance of the future George I Rákóczi in another anti-Habsburg insurrection. By the Peace of Nikolsburg in 1621, the Habsburgs restored the religious toleration agreement of 1606 and recognized Transylvanian rule over the seven Partium countries: Ugocsa, Bereg, Zemplen, Borsod, Szabolcs, Szatmar and Abauj. The county again belonged to the Principality of Transylvania between 1644-48. Battles were also fought in the county in the early 18th century, during the revolutions led by Imre Thököly and Francis II Rákóczi. The Abaúj county was first merged with the neighbouring, smaller County of Torna (Slovak: Turňa) county in 1785, at the order of Joseph II, but they were separated again in 1790. After the 1848-49 revolution had been suppressed, Abaúj and Torna were merged again, but were separated in 1859. They were finally merged in 1882. Before the merging Abaúj had an area of 2872,71 km² and a population of 166,666; Torna had an area of 618,04 km² and a population of 23,176. In 1919(?) Abaúj-Torna had 364 villages, of which only 5 had a population larger than 2000. Of the 63 counties of the Kingdom, it was the 45th largest by area, 37th largest by population and 35th by population density (65/km² in 1910). Between 1899 and 1913 many of people left the Kingdom of Hungary and emigrated to other countries; from Abaúj 44,258 people emigrated, 13,566 migrated back to Hungary; in total it had 30,692 émigrés, making it the 8th largest emigration source of all counties. In 1918 (confirmed by the Treaty of Trianon 1920), the northern half of the Abaúj-Torna county (1551 km², including Kassa/Košice) became part of newly formed Czechoslovakia and continued to exist as an administrative unit till October 26, 1922, under the name Abovskoturnianska župa. The southern half became part of modern Hungary as the county Abaúj-Torna, with capital Szikszó. The Hungarian part was divided into four districts. During World War II Czechoslovakia was split and on November 2, 1938, most of the Czechoslovak part of the county (1257 km² with a population of 126,050, including Kassa with an area of 93 km² and a population of 58,090) became part of Hungary under the First Vienna Award, and was added