On January 18, 1644, the Diet in Kassa elected George I Rákóczi the prince of Hungary. He took the whole of Upper Hungary and joined the Swedish army besieging Brno for a projected march against Vienna. However, his nominal overlord, the Ottoman Sultan, ordered him to end the campaign, but he did so with gains. In the Treaty of Linz (1645), Kassa returned to Transylvania again as the Habsburgs recognized George's rule over the seven counties of the Partium. He died in 1648, and Kassa was returned to the Habsburgs once more.