King Matthias Corvinus of Hungary gave the town to one of his relatives, János Pongrác Dengelegi, who, fearing an invasion by the Ottoman Empire, fortified the castle of Subotica, erecting a fortress in 1470. Some decades later, after the Battle of Mohács in 1526, Subotica became part of the Ottoman Empire. The majority of the Hungarian population fled northward to Royal Hungary. Bálint Török, a local noble who had ruled over Subotica, also escaped from the city. During the military and political havoc following the defeat at Mohács, Subotica came under the control of Serbian mercenaries recruited in Banat. These soldiers were in the service of the Transylvanian general John I Zápolya, a later Hungarian king.